Skip to content

Commit

Permalink
Avoid usage of global "Vue"
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Jan 8, 2025
1 parent 9d1cef3 commit 6ac9750
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
6 changes: 2 additions & 4 deletions resources/js/bootstrap/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ export default {
setupMoment() {
const locale = Statamic.$config.get('locale');
window.moment.locale(locale);
Vue.moment.locale(locale);
Vue.prototype.$moment.locale(locale);
this.$moment.locale(locale);
const spec = {
relativeTime: {
Expand All @@ -236,8 +235,7 @@ export default {
}
};
window.moment.updateLocale(locale, spec);
Vue.moment.updateLocale(locale, spec);
Vue.prototype.$moment.updateLocale(locale, spec);
this.$moment.updateLocale(locale, spec);
}
}
Expand Down
6 changes: 3 additions & 3 deletions resources/js/components/SessionExpiry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
errors: {},
password: null,
pinging: false,
lastCount: Vue.moment(),
lastCount: moment(),
isPageHidden: false,
}
},
Expand Down Expand Up @@ -113,14 +113,14 @@ export default {
// Javascript is being executed, but the count will have stopped if the computer
// has been put to sleep. If it's been a while since the last count, we'll
// also perform a timeout check. This will let things recalibrate.
const secondsSinceLastCount = Vue.moment().diff(this.lastCount, 'seconds');
const secondsSinceLastCount = moment().diff(this.lastCount, 'seconds');
const itsBeenAWhile = secondsSinceLastCount > 10;
if (withinWarningPeriod || itsBeenAWhile) {
this.ping().catch(e => {});
}
this.lastCount = Vue.moment();
this.lastCount = moment();
},
isShowingLogin(showing, wasShowing) {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/RegularField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
labelText() {
return this.field.config.display
|| Vue.options.filters.titleize(Vue.options.filters.deslugify(this.field.handle));
|| this.$filters.titleize(this.$filters.deslugify(this.field.handle));
},
width: {
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/data-list/HasFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export default {

filterChanged({ handle, values }, unselectAll = true) {
if (values && this.hasFields(values)) {
Vue.set(this.activeFilters, handle, values);
this.activeFilters[handle] = values;
} else {
Vue.delete(this.activeFilters, handle);
delete this.activeFilters[handle];
}
if (unselectAll) this.unselectAllItems();
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/login/LoginModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
mounted() {
this.$http.get(cp_url('auth/token')).success(response => {
Vue.http.headers.common['X-CSRF-TOKEN'] = response;
this.$http.headers.common['X-CSRF-TOKEN'] = response;
});
this.$refs.password.focus();
Expand Down
8 changes: 4 additions & 4 deletions resources/js/components/nav/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export default {
if (currentAction === '@create' || value !== data_get(item.original, key)) {
item.manipulations[key] = value;
} else {
Vue.delete(item.manipulations, key);
delete item.manipulations[key];
}
},
Expand All @@ -567,7 +567,7 @@ export default {
if (detectedAction) {
item.manipulations.action = detectedAction;
} else {
Vue.delete(item.manipulations, 'action');
delete item.manipulations['action'];
}
if (this.isChildItemNode(item)) {
Expand Down Expand Up @@ -749,15 +749,15 @@ export default {
},
hideItem(item) {
Vue.set(item.manipulations, 'action', '@hide');
item.manipulations['action'] = '@hide';
this.updateItemAction(item);
this.changed = true;
},
showItem(item) {
Vue.delete(item.manipulations, 'action');
delete item.manipulations['action'];
this.updateItemAction(item);
Expand Down
8 changes: 6 additions & 2 deletions resources/js/components/publish/Field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export default {
},
fieldtypeComponentExists() {
return Vue.options.components[this.fieldtypeComponent] !== undefined;
if (! Statamic.$app.component(this.fieldtypeComponent)) {
console.warn('unsupported fieldtype: ' + this.fieldtypeComponent);
}
return Statamic.$app.component(this.fieldtypeComponent) !== undefined;
},
instructions() {
Expand Down Expand Up @@ -214,7 +218,7 @@ export default {
labelText() {
return this.config.display
|| Vue.$options.filters.titleize(Vue.$options.filters.deslugify(this.config.handle));
|| this.$filters.titleize(this.$filters.deslugify(this.config.handle));
},
showLabelText() {
Expand Down

0 comments on commit 6ac9750

Please sign in to comment.