Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/loader #67

Merged
merged 19 commits into from
Jul 11, 2018
Merged

Feature/loader #67

merged 19 commits into from
Jul 11, 2018

Conversation

kjugi
Copy link
Contributor

@kjugi kjugi commented Jun 8, 2018

Add loader to button while clicking on it after filling up form with data. Must validate first and then showing loader and blocking button to prevent multiple clicks and sending multiple requests.

Modify button props.
Add styles to button
Create loader components with styles

class="button"
:type="buttonType"
:title="buttonTitle"
:disabled="isBlocked"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can set disabled button if prop withLoader is true?

Copy link
Contributor Author

@kjugi kjugi Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prop withLoader is not a loader state. It's like a variant for the button. You can set button without or with loader. So I can't disable the button when withLoader is true b/c it will be disabled it on start

components: {
BaseLoader
},
props: ['buttonType', 'text', 'buttonTitle', 'withLoader'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change props? Prev version was ok. We should add require property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to cahnge prop withLoader to loader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think prop loader means it will enable loader or start the loader. In this situation, withLoader means it will show the button with loader option. You can also show normal button without it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I changed props b/c prev we just have type: String without require property

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So better is to add require true or false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


<template v-if="withLoader">
<BaseLoader/>
</template>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move v-if="withLoader" to BaseLoader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b/c it's variant for button. Not always you want to show button with loader. I.e when have 2 buttons and one is "Place order" and the second is "Back"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it does not metter you can move condition to BaseLoader, like below

<BaseLoader  v-if="withLoader"/>

in this case we dont need temlate tag

}

&:disabled {
opacity: .5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it works but please change to opacity: 0.5;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

begin="0.3"
/>
</circle>
</svg>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please minify svg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added svg-loader and add icon to assets + minify it and change styles to non scoped to get it in loader

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -51,7 +51,8 @@ const store = new Vuex.Store({
shippingCarrierCode: '',
shippingMethodCode: ''
},
totals: null
totals: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you changed to empty object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol idk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And want to see it it working or no. For now we are not setting to totals anything. Is it ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for now we don't use this state

this.$store.commit('setLoading', true)
this.regions = this.$store.getters.regionsByCountryId(this.address.country_id)
this.$store.dispatch('updateShippingMethods', this.address.country_id)
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method. Where do you execute it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like some dead code - deleted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kjugi kjugi self-assigned this Jun 15, 2018
@@ -61,7 +61,7 @@
In this country we don't handle any shipping methods.
</p>
</template>
<BaseButton class="button" button-type="submit" text="Next Step"/>
<BaseButton class="button" button-type="submit" text="Next Step" with-loader="true"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change with-loader="true" to with-loader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -50,6 +50,7 @@
class="button"
button-type="button"
text="Place order"
with-loader="true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change with-loader="true" to with-loader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -105,13 +106,19 @@ export default {
this.$validator.validateAll().then((result) => {
if (result) {
EventBus.$emit('save-address', 'billingAddress')
this.$store.commit('setLoading', true)
this.$store.commit('setAddress', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add above this commit?

Filip Kudła added 4 commits July 9, 2018 13:47
Conflicts:
	view/frontend/web/js/components/BaseButton.vue
	view/frontend/web/js/components/steps/TheShippingStep.vue
	yarn.lock
@kjugi
Copy link
Contributor Author

kjugi commented Jul 10, 2018

If we want to add loader on start than must deal with v-cloak and add some styles to loader

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg"><circle cx="4" cy="4" r="4"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin=".1"/></circle><circle cx="18" cy="4" r="4"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin=".2"/></circle><circle cx="32" cy="4" r="4"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin=".3"/></circle></svg>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line :D


<template v-if="withLoader">
<BaseLoader/>
</template>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it does not metter you can move condition to BaseLoader, like below

<BaseLoader  v-if="withLoader"/>

in this case we dont need temlate tag

@szafran89
Copy link
Contributor

@kjugi just 2 comments to fix ;)

@kjugi
Copy link
Contributor Author

kjugi commented Jul 11, 2018

Closes #26

@kjugi kjugi merged commit 8a71f51 into develop Jul 11, 2018
@kjugi kjugi deleted the feature/loader branch July 11, 2018 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants