Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-01-25 17:15:48 +0300
committerFatih Acet <acetfatih@gmail.com>2017-02-03 17:02:43 +0300
commit240d8c8d307e4675e72d854f4d70d722075c02c4 (patch)
treebf34b3810b69647ce4cf4b202f00120d20cc84cf /app/assets/javascripts/boards/stores
parentacd86c120f012b38108971ec466c6c141405f1d1 (diff)
Created a modal store
Diffstat (limited to 'app/assets/javascripts/boards/stores')
-rw-r--r--app/assets/javascripts/boards/stores/modal_store.js.es663
1 files changed, 63 insertions, 0 deletions
diff --git a/app/assets/javascripts/boards/stores/modal_store.js.es6 b/app/assets/javascripts/boards/stores/modal_store.js.es6
new file mode 100644
index 00000000000..68f5e57a154
--- /dev/null
+++ b/app/assets/javascripts/boards/stores/modal_store.js.es6
@@ -0,0 +1,63 @@
+(() => {
+ window.gl = window.gl || {};
+ window.gl.issueBoards = window.gl.issueBoards || {};
+
+ class ModalStore {
+ constructor() {
+ this.globalStore = gl.issueBoards.BoardsStore.modal;
+ }
+
+ selectedCount() {
+ return this.globalStore.selectedIssues.length;
+ }
+
+ toggleIssue(issueObj) {
+ const issue = issueObj;
+ issue.selected = !issue.selected;
+
+ if (issue.selected) {
+ this.addSelectedIssue(issue);
+ } else {
+ this.removeSelectedIssue(issue);
+ }
+ }
+
+ toggleAll() {
+ const select = this.selectedCount() !== this.globalStore.issues.length;
+
+ this.globalStore.issues.forEach((issue) => {
+ const issueUpdate = issue;
+
+ if (issueUpdate.selected !== select) {
+ issueUpdate.selected = select;
+
+ if (select) {
+ this.addSelectedIssue(issue);
+ } else {
+ this.removeSelectedIssue(issue);
+ }
+ }
+ });
+ }
+
+ addSelectedIssue(issue) {
+ this.globalStore.selectedIssues.push(issue);
+ }
+
+ removeSelectedIssue(issue) {
+ const index = this.selectedIssueIndex(issue);
+ this.globalStore.selectedIssues.splice(index, 1);
+ }
+
+ selectedIssueIndex(issue) {
+ return this.globalStore.selectedIssues.indexOf(issue);
+ }
+
+ findSelectedIssue(issue) {
+ return this.globalStore.selectedIssues
+ .filter(filteredIssue => filteredIssue.id === issue.id)[0];
+ }
+ }
+
+ gl.issueBoards.ModalStore = new ModalStore();
+})();