Browse Source

feat: added button to select/deselect all accounts on convert page

Kristian Vos 4 years ago
parent
commit
f4af312c41
2 changed files with 35 additions and 0 deletions
  1. 28 0
      frontend/vue/pages/ConvertAccounts.vue
  2. 7 0
      frontend/yarn.lock

+ 28 - 0
frontend/vue/pages/ConvertAccounts.vue

@@ -7,6 +7,10 @@
 		<button @click="importConvertSchema()" class="button">Import convert schema</button>
 		<br/>
 		<br/>
+		<p>Select/deselect all:</p>
+		<button class="button" v-for="version in versions" @click="toggleVersion(version)">{{version}}</button>
+		<br/>
+		<br/>
 		<data-table ref="datatable"
 			:fields="fields"
 			:sort-order="sortOrder"
@@ -40,6 +44,7 @@ export default {
 	data: () => {
 		return {
 			accounts: [],
+			versions: [],
 			selectedAccounts: [],
 			convertingAccounts: false,
 			fields: [
@@ -103,6 +108,25 @@ export default {
 			const selectedAccountIndex = this.selectedAccounts.indexOf(accountId);
 			if (selectedAccountIndex === -1) this.selectedAccounts.push(accountId);
 			else this.selectedAccounts.splice(selectedAccountIndex, 1);
+		},
+		toggleVersion(version) {
+			let allAccountsChecked = true;
+			this.accounts.forEach(account => {
+				if (account.version === version && this.selectedAccounts.indexOf(account._id) === -1) allAccountsChecked = false;
+			});
+
+			let toggleTo;
+
+			if (allAccountsChecked) toggleTo = false;
+			else toggleTo = true;
+
+			this.accounts.forEach(account => {
+				if (account.version === version) {
+					let selectedAccountIndex = this.selectedAccounts.indexOf(account._id);
+					if (toggleTo && selectedAccountIndex === -1) this.selectedAccounts.push(account._id);
+					if (!toggleTo && selectedAccountIndex !== -1) this.selectedAccounts.splice(selectedAccountIndex, 1);
+				}
+			});
 		}
 	},
 	mounted() {
@@ -113,6 +137,10 @@ export default {
 				console.log(res);
 				this.accounts = res.accounts;
 			});
+
+			socket.emit("accountSchema.getAllVersions", res => {
+				this.versions = res.versions;
+			});
 		});
 	}
 };

+ 7 - 0
frontend/yarn.lock

@@ -1065,6 +1065,13 @@ concat-stream@^1.5.0:
     readable-stream "^2.2.2"
     typedarray "^0.0.6"
 
+config@^3.2.2:
+  version "3.2.4"
+  resolved "https://registry.yarnpkg.com/config/-/config-3.2.4.tgz#e60a908582991e800852f9cb60fcf424f3274a6c"
+  integrity sha512-H1XIGfnU1EAkfjSLn9ZvYDRx9lOezDViuzLDgiJ/lMeqjYe3q6iQfpcLt2NInckJgpAeekbNhQkmnnbdEDs9rw==
+  dependencies:
+    json5 "^1.0.1"
+
 connect-history-api-fallback@^1.6.0:
   version "1.6.0"
   resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc"