Skip to content

Commit

Permalink
default theme 1.5 to 1.6 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
filrak committed Dec 3, 2018
1 parent 0c569ef commit cc17b5b
Show file tree
Hide file tree
Showing 105 changed files with 1,851 additions and 649 deletions.
11 changes: 5 additions & 6 deletions src/themes/migration/components/core/AddToCart.vue
Expand Up @@ -4,22 +4,21 @@
</button-full>
</template>

<script lang="ts">
import Product from '@vue-storefront/store/types/product/Product'
import { formatProductMessages } from '@vue-storefront/core/filters/product-messages/typed'
<script>
import { formatProductMessages } from '@vue-storefront/core/filters/product-messages'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Filer and it's typed version merged into one.

Correct import.

import focusClean from 'theme/components/theme/directives/focusClean'
import ButtonFull from 'theme/components/theme/ButtonFull.vue'
import addToCart from '@vue-storefront/core/components/AddToCart'
import { AddToCart } from '@vue-storefront/core/modules/cart/components/AddToCart'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to module.

Correct import.

export default {
mixins: [addToCart],
mixins: [AddToCart],
directives: { focusClean },
components: { ButtonFull },
methods: {
onAfterRemovedVariant () {
this.$forceUpdate()
},
canBeAdded (product: Product): boolean {
canBeAdded (product) {
return formatProductMessages(product.errors) !== ''
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/Breadcrumbs.vue
Expand Up @@ -12,7 +12,7 @@
</template>

<script>
import Breadcrumbs from '@vue-storefront/core/components/Breadcrumbs'
import Breadcrumbs from '@vue-storefront/core/compatibility/components/Breadcrumbs'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility

Correct import.

export default {
mixins: [Breadcrumbs]
Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/ColorSelector.vue
Expand Up @@ -12,7 +12,7 @@
</template>

<script>
import GenericSelector from '@vue-storefront/core/components/GenericSelector'
import GenericSelector from '@vue-storefront/core/compatibility/components/GenericSelector'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility

Correct import.

export default {
mixins: [GenericSelector],
Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/GenericSelector.vue
Expand Up @@ -10,7 +10,7 @@
</template>

<script>
import GenericSelector from '@vue-storefront/core/components/GenericSelector'
import GenericSelector from '@vue-storefront/core/compatibility/components/GenericSelector'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility

Correct import.

export default {
mixins: [GenericSelector]
}
Expand Down
29 changes: 27 additions & 2 deletions src/themes/migration/components/core/Loader.vue
Expand Up @@ -16,10 +16,35 @@
</template>

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Logic moved to theme component

Remove import and add moved logic..


<script>
import Loader from '@vue-storefront/core/components/Loader'
import { mapState } from 'vuex'
export default {
mixins: [Loader]
name: 'Loader',
data () {
return {
message: null
}
},
methods: {
show (message = null) {
this.message = message
this.$store.commit('ui/setLoader', true)
},
hide () {
this.$store.commit('ui/setLoader', false)
}
},
computed: mapState({
isVisible: state => state.ui.loader
}),
beforeMount () {
this.$bus.$on('notification-progress-start', this.show)
this.$bus.$on('notification-progress-stop', this.hide)
},
beforeDestroy () {
this.$bus.$off('notification-progress-start', this.show)
this.$bus.$off('notification-progress-stop', this.hide)
}
}
</script>

Expand Down
64 changes: 54 additions & 10 deletions src/themes/migration/components/core/Modal.vue
Expand Up @@ -20,9 +20,8 @@
</i>

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Logic moved to theme component

Remove import and add moved logic..

<slot name="header"/>
</header>
<div class="modal-content pt30 pb60 px65" v-if="$slots.content || staticData">
<div class="modal-content pt30 pb60 px65" v-if="$slots.content">

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Removed static content from modal.

Delete static content side effects from methods and template.

<slot name="content"/>
<static-content :file="staticData" v-if="staticData"/>
</div>
<slot/>
</div>
Expand All @@ -33,18 +32,63 @@
</template>

<script>
import StaticContent from 'theme/components/theme/StaticContent'
import Modal from '@vue-storefront/core/components/Modal'
import { mapMutations } from 'vuex'
import onEscapePress from '@vue-storefront/core/mixins/onEscapePress'
export default {
components: {
StaticContent
name: 'Modal',
data () {
return {
isVisible: false
}
},
methods: {
onHide (name, state, params) {
return name === this.name ? this.toggle(false) : false
},
onShow (name, state, params) {
return name === this.name ? this.toggle(true) : false
},
onToggle (name, state, params) {
if (name === this.name) {
state = typeof state === 'undefined' ? !this.isVisible : state
this.toggle(state)
}
},
onEscapePress () {
this.close()
},
...mapMutations('ui', [
'setOverlay'
]),
toggle (state) {
this.isVisible = state
state ? this.setOverlay(state) : setTimeout(() => this.setOverlay(state), this.delay)
},
close () {
this.toggle(false)
}
},
beforeMount () {
this.$bus.$on('modal-toggle', this.onToggle)
this.$bus.$on('modal-show', this.onShow)
this.$bus.$on('modal-hide', this.onHide)
},
mixins: [Modal],
beforeDestroy () {
this.$bus.$off('modal-toggle', this.onToggle)
this.$bus.$off('modal-show', this.onShow)
this.$bus.$off('modal-hide', this.onHide)
},
mixins: [onEscapePress],
props: {
staticData: {
type: String,
default: ''
name: {
required: true,
type: String
},
delay: {
required: false,
type: Number,
default: 300
},
width: {
type: Number,
Expand Down
6 changes: 3 additions & 3 deletions src/themes/migration/components/core/NewsletterPopup.vue
Expand Up @@ -41,7 +41,7 @@
</modal>
</template>
<script>
import { Subscribe } from '@vue-storefront/core/modules/mailchimp/components/Subscribe'
import { Subscribe } from 'src/modules/mailchimp/components/Subscribe'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility

Correct import.

import i18n from '@vue-storefront/i18n'
import ButtonFull from 'theme/components/theme/ButtonFull.vue'
Expand All @@ -54,10 +54,10 @@ export default {
},
methods: {
onSuccesfulSubmission () {
this.$bus.$emit('notification', {
this.$store.dispatch('notification/spawnNotification', {

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Notifications are niow based on Vuex Store instead of Event Bus. See notification module for details.

Replace all this.$bus.$emit('notification' with this.$store.dispatch('notification/spawnNotification'

type: 'success',
message: i18n.t('You have been successfully subscribed to our newsletter!'),
action1: { label: i18n.t('OK'), action: 'close' }
action1: { label: i18n.t('OK') }

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Empty actions are by default hiding the notification.

Remove action: 'close'. It still works as intended if not removed as backward compatible.

})
this.$bus.$emit('modal-hide', 'modal-newsletter')
}
Expand Down
23 changes: 18 additions & 5 deletions src/themes/migration/components/core/Notification.vue
Expand Up @@ -8,7 +8,7 @@
:class="notification.type"
>
<div
@click="action(notification.action1.action, index)"
@click="execAction(notification.action1, index)"

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

action function responsible for invoking notification action callback was renamed to execAction.

Rename action with execAction

class="message p20"
data-testid="notificationMessage"
>
Expand All @@ -20,15 +20,15 @@
:class="`border-${notification.type}`"
id="notificationAction1"
data-testid="notificationAction1"
@click="action(notification.action1.action, index, notification)"
@click="execAction(notification.action1, index)"
>
{{ notification.action1.label }}
</div>
<div
class="py10 px20 pointer weight-400 notification-action uppercase"
id="notificationAction2"
data-testid="notificationAction2"
@click="action(notification.action2.action, index, notification)"
@click="execAction(notification.action2, index)"
v-if="notification.action2"
>
{{ notification.action2.label }}
Expand All @@ -40,10 +40,23 @@
</template>

<script>
import Notification from '@vue-storefront/core/components/Notification'
import { Notification } from '@vue-storefront/core/modules/notification/components/Notification'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Component moved to module.

Correct import.

export default {
mixins: [Notification]
mixins: [Notification],
methods: {

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Theme-specific execAction.

Add execAction method.

execAction (action, index) {
if (action.action) {
// for backward compatibility
if (action.action === 'close') {
this.$store.dispatch('notification/removeNotification', index)
} else {
action.action()
}
}
this.$store.dispatch('notification/removeNotification', index)
}
}
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/Overlay.vue
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import Overlay from '@vue-storefront/core/components/Overlay'
import Overlay from '@vue-storefront/core/compatibility/components/Overlay'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility.

Correct import.

export default {
mixins: [Overlay],
Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/PriceSelector.vue
Expand Up @@ -12,7 +12,7 @@
</template>

<script>
import PriceSelector from '@vue-storefront/core/components/PriceSelector'
import PriceSelector from '@vue-storefront/core/compatibility/components/PriceSelector'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility.

Correct import.

export default {
mixins: [PriceSelector]
Expand Down
2 changes: 1 addition & 1 deletion src/themes/migration/components/core/ProductAttribute.vue
Expand Up @@ -6,7 +6,7 @@
</template>

<script>
import ProductAttribute from '@vue-storefront/core/components/ProductAttribute'
import { ProductAttribute } from '@vue-storefront/core/modules/catalog/components/ProductAttribute.ts'

This comment has been minimized.

Copy link
@filrak

filrak Dec 3, 2018

Author Collaborator

Moved to compatibility.

Correct import.

export default {
mixins: [ProductAttribute]
Expand Down

0 comments on commit cc17b5b

Please sign in to comment.