Remove store logic from issue board models
This is part of refactoring issue boards to Vuex (&1278 (closed)) and needs to happen after gitlab-foss#61293 (closed) and #28616 (closed).
Move any logic that happens in app/assets/javascripts/boards/models/
to the boards store (ideally one function at a time)
Example
Before
save() {
const entity = this.label || this.assignee || this.milestone;
let entityType = '';
if (this.label) {
entityType = 'label_id';
} else if (this.assignee) {
entityType = 'assignee_id';
} else if (IS_EE && this.milestone) {
entityType = 'milestone_id';
}
return boardsStore
.createList(entity.id, entityType)
.then(res => res.data)
.then(data => {
this.id = data.id;
this.type = data.list_type;
this.position = data.position;
this.label = data.label;
return this.getIssues();
});
}
(app/assets/javascripts/boards/models/list.js)
After
save() {
return boardsStore.saveList(this);
}
(app/assets/javascripts/boards/models/list.js)
new function in boards store:
saveList(list) {
const entity = list.label || list.assignee || list.milestone;
let entityType = '';
if (list.label) {
entityType = 'label_id';
} else if (list.assignee) {
entityType = 'assignee_id';
} else if (IS_EE && list.milestone) {
entityType = 'milestone_id';
}
return this.createList(entity.id, entityType)
.then(res => res.data)
.then(data => {
list.id = data.id;
list.type = data.list_type;
list.position = data.position;
list.label = data.label;
return list.getIssues();
});
}
(app/assets/javascripts/boards/stores/boards_store.js)
Edited by Inactive Account