Skip to content

Commit

Permalink
Migrate use of Vue.set()
Browse files Browse the repository at this point in the history
  • Loading branch information
mzur committed Jan 10, 2025
1 parent aababf3 commit 4958b71
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion resources/assets/js/annotations/annotatorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export default {
// Mark for deletion so the annotation is immediately removed from
// the canvas. See https://github.com/biigle/annotations/issues/70
Vue.set(annotation, 'markedForDeletion', true);
annotation.markedForDeletion = true;
AnnotationsStore.delete(annotation)
.catch(function (response) {
annotation.markedForDeletion = false;
Expand Down
6 changes: 3 additions & 3 deletions resources/assets/js/core/models/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default Vue.extend({
} else if (this.has(key)) {
this.data[key] = value;
} else {
Vue.set(this.data, key, value);
this.data[key] = value;
}
debounce(this.persist, 100, this.storageKey);
Expand All @@ -45,15 +45,15 @@ export default Vue.extend({
restoreFromLocalStorage() {
let data = JSON.parse(window.localStorage.getItem(this.storageKey));
if (data) {
Vue.set(this, 'data', data);
this.data = data;
}
},
restoreFromUrlParams(keys) {
let params = urlParams.params;
keys = keys || Object.keys(params);
keys.forEach((key) => {
if (params.hasOwnProperty(key)) {
Vue.set(this.data, key, params[key]);
this.data[key] = params[key];
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
methods: {
fetchOwnProjects() {
ProjectsApi.query().then((response) => {
Vue.set(this, 'ownProjects', response.body);
this.ownProjects = response.body;
}, handleErrorResponse);
},
addAuthorizedProject(project) {
Expand Down
10 changes: 5 additions & 5 deletions resources/assets/js/label-trees/components/labelTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export default {
// update the label children with the compiled datastructure
this.labels.forEach(function (label) {
if (compiled.hasOwnProperty(label.id)) {
Vue.set(label, 'children', compiled[label.id]);
label.children = compiled[label.id];
} else {
Vue.set(label, 'children', undefined);
label.children = undefined;
// If the last child was deleted, close the label.
label.open = false;
}
Expand Down Expand Up @@ -305,15 +305,15 @@ export default {
// Set the reactive label properties
this.labels.forEach(function (label) {
if (!label.hasOwnProperty('open')) {
Vue.set(label, 'open', false);
label.open = false;
}
if (!label.hasOwnProperty('selected')) {
Vue.set(label, 'selected', false);
label.selected = false;
}
if (!label.hasOwnProperty('favourite')) {
Vue.set(label, 'favourite', false);
label.favourite = false;
}
});
Expand Down
4 changes: 2 additions & 2 deletions resources/assets/js/label-trees/labelsContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default {
this.selectedName = name;
},
insertLabel(label) {
Vue.set(label, 'open', false);
Vue.set(label, 'selected', false);
label.open = false;
label.selected = false;
let name = label.name.toLowerCase();
// add the label to the array so the labels remain sorted by their name
for (let i = 0, length = this.labels.length; i < length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/sync/components/entityChooser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
},
methods: {
handleSelect(entity) {
Vue.set(this.chosenIds, entity.id, true);
this.chosenIds[entity.id] = true;
},
handleDeselect(entity) {
this.chosenIds[entity.id] = false;
Expand Down
8 changes: 4 additions & 4 deletions resources/assets/js/sync/mixins/labelTreeImportContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ export default {
},
chooseImportParent(label) {
if (this.hasLabelConflictingParent(label)) {
Vue.set(label, 'conflicting_parent_resolution', 'import');
label.conflicting_parent_resolution = 'import';
}
},
chooseImportName(label) {
if (this.hasLabelConflictingName(label)) {
Vue.set(label, 'conflicting_name_resolution', 'import');
label.conflicting_name_resolution = 'import';
}
},
chooseExistingParent(label) {
if (this.hasLabelConflictingParent(label)) {
Vue.set(label, 'conflicting_parent_resolution', 'existing');
label.conflicting_parent_resolution = 'existing';
}
},
chooseExistingName(label) {
if (this.hasLabelConflictingName(label)) {
Vue.set(label, 'conflicting_name_resolution', 'existing');
label.conflicting_name_resolution = 'existing';
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/sync/volumeImportContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
computed: {
volumes() {
return this.volumeCandidates.map(function (volume) {
Vue.set(volume, 'new_url', volume.url);
volume.new_url = volume.url;
if (volume.media_type_name === 'image') {
volume.icon = 'image';
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/volumes/annotationSessionPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default {
response.data.forEach(function (user) {
user.name = user.firstname + ' ' + user.lastname;
});
Vue.set(this, 'users', response.data);
this.users = response.data;
},
selectUser(user) {
this.editedSession.users.push(user);
Expand Down

0 comments on commit 4958b71

Please sign in to comment.