Commit f89782b3 authored by Phil Hughes's avatar Phil Hughes

Changed store

Async updates the boards when searching
parent 850f19c0
...@@ -27,8 +27,6 @@ $(() => { ...@@ -27,8 +27,6 @@ $(() => {
const Store = gl.issueBoards.BoardsStore; const Store = gl.issueBoards.BoardsStore;
const ModalStore = gl.issueBoards.ModalStore; const ModalStore = gl.issueBoards.ModalStore;
new FilteredSearchBoards();
window.gl = window.gl || {}; window.gl = window.gl || {};
if (gl.IssueBoardsApp) { if (gl.IssueBoardsApp) {
...@@ -62,6 +60,8 @@ $(() => { ...@@ -62,6 +60,8 @@ $(() => {
}, },
created () { created () {
gl.boardService = new BoardService(this.endpoint, this.bulkUpdatePath, this.boardId); gl.boardService = new BoardService(this.endpoint, this.bulkUpdatePath, this.boardId);
new FilteredSearchBoards(Store.filter);
}, },
mounted () { mounted () {
Store.disabled = this.disabled; Store.disabled = this.disabled;
......
...@@ -28,16 +28,16 @@ require('./board_list'); ...@@ -28,16 +28,16 @@ require('./board_list');
data () { data () {
return { return {
detailIssue: Store.detail, detailIssue: Store.detail,
filters: Store.state.filters, filter: Store.filter,
}; };
}, },
watch: { watch: {
filters: { filter: {
handler () { handler() {
this.list.page = 1; this.list.page = 1;
this.list.getIssues(true); this.list.getIssues(true);
}, },
deep: true deep: true,
}, },
detailIssue: { detailIssue: {
handler () { handler () {
......
export default class FilteredSearchBoards extends gl.FilteredSearchManager { export default class FilteredSearchBoards extends gl.FilteredSearchManager {
constructor() { constructor(store) {
super('boards'); super('boards');
this.store = store;
this.destroyOnSubmit = false
}
updateObject(path) {
this.store.path = path.substr(1);
} }
} }
...@@ -10,7 +10,7 @@ class List { ...@@ -10,7 +10,7 @@ class List {
this.title = obj.title; this.title = obj.title;
this.type = obj.list_type; this.type = obj.list_type;
this.preset = ['done', 'blank'].indexOf(this.type) > -1; this.preset = ['done', 'blank'].indexOf(this.type) > -1;
this.filters = gl.issueBoards.BoardsStore.state.filters; this.filterPath = gl.issueBoards.BoardsStore.filter.path;
this.page = 1; this.page = 1;
this.loading = true; this.loading = true;
this.loadingMore = false; this.loadingMore = false;
...@@ -65,12 +65,24 @@ class List { ...@@ -65,12 +65,24 @@ class List {
} }
getIssues (emptyIssues = true) { getIssues (emptyIssues = true) {
const filters = this.filters;
const data = { page: this.page }; const data = { page: this.page };
gl.issueBoards.BoardsStore.filter.path.split('&').forEach((filterParam) => {
const paramSplit = filterParam.split('=');
const paramKeyNormalized = paramSplit[0].replace('[]', '');
const isArray = paramSplit[0].indexOf('[]');
Object.keys(filters).forEach((key) => { data[key] = filters[key]; }); if (isArray >= 0) {
if (!data[paramKeyNormalized]) {
data[paramKeyNormalized] = [];
}
if (this.label) { data[paramKeyNormalized].push(paramSplit[1]);
} else {
data[paramKeyNormalized] = paramSplit[1];
}
});
if (this.label && data.label_name) {
data.label_name = data.label_name.filter(label => label !== this.label.title); data.label_name = data.label_name.filter(label => label !== this.label.title);
} }
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
gl.issueBoards.BoardsStore = { gl.issueBoards.BoardsStore = {
disabled: false, disabled: false,
filter: {
path: '',
},
state: {}, state: {},
detail: { detail: {
issue: {} issue: {}
...@@ -18,13 +21,7 @@ ...@@ -18,13 +21,7 @@
}, },
create () { create () {
this.state.lists = []; this.state.lists = [];
this.state.filters = { this.filter.path = gl.utils.getUrlParamsArray().join('&');
author_username: gl.utils.getParameterValues('author_username')[0],
assignee_username: gl.utils.getParameterValues('assignee_username')[0],
milestone_title: gl.utils.getParameterValues('milestone_title')[0],
label_name: gl.utils.getParameterValues('label_name[]'),
search: ''
};
}, },
addList (listObj) { addList (listObj) {
const list = new List(listObj); const list = new List(listObj);
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
if (!activeElements.length) { if (!activeElements.length) {
// Prevent droplab from opening dropdown // Prevent droplab from opening dropdown
this.dropdownManager.destroyDroplab(); //this.dropdownManager.destroyDroplab();
this.search(); this.search();
} }
...@@ -345,8 +345,12 @@ ...@@ -345,8 +345,12 @@
const parameterizedUrl = `?scope=all&utf8=✓&${paths.join('&')}`; const parameterizedUrl = `?scope=all&utf8=✓&${paths.join('&')}`;
if (this.updateObject) {
this.updateObject(parameterizedUrl);
} else {
gl.utils.visitUrl(parameterizedUrl); gl.utils.visitUrl(parameterizedUrl);
} }
}
getUsernameParams() { getUsernameParams() {
const usernamesById = {}; const usernamesById = {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment