Add writing of query params

pull/111/head
MattIPv4 2020-05-05 16:29:13 +01:00
parent 795edd2255
commit f2c0878cda
4 changed files with 27 additions and 6 deletions

11
package-lock.json generated
View File

@ -6334,9 +6334,9 @@
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
}, },
"qs": { "qs": {
"version": "6.5.2", "version": "6.9.4",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ=="
}, },
"querystring": { "querystring": {
"version": "0.2.0", "version": "0.2.0",
@ -6556,6 +6556,11 @@
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"dependencies": { "dependencies": {
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"tough-cookie": { "tough-cookie": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",

View File

@ -38,6 +38,7 @@
"do-vue": "git+https://github.com/do-community/do-vue.git", "do-vue": "git+https://github.com/do-community/do-vue.git",
"parcel-bundler": "^1.12.4", "parcel-bundler": "^1.12.4",
"pretty-checkbox-vue": "^1.1.9", "pretty-checkbox-vue": "^1.1.9",
"qs": "^6.9.4",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-hot-reload-api": "^2.3.3", "vue-hot-reload-api": "^2.3.3",
"vue-select": "^3.10.3", "vue-select": "^3.10.3",

View File

@ -46,7 +46,7 @@
<input v-model="shareLink" <input v-model="shareLink"
class="input" class="input"
type="text" type="text"
disabled="disabled" readonly="readonly"
/> />
</div> </div>
</div> </div>
@ -108,6 +108,7 @@
<script> <script>
import PrettyCheck from 'pretty-checkbox-vue/check'; import PrettyCheck from 'pretty-checkbox-vue/check';
import qs from 'qs';
import i18n from '../../i18n'; import i18n from '../../i18n';
import delegatedFromDefaults from '../../util/delegated_from_defaults'; import delegatedFromDefaults from '../../util/delegated_from_defaults';
import computedFromDefaults from '../../util/computed_from_defaults'; import computedFromDefaults from '../../util/computed_from_defaults';
@ -145,8 +146,19 @@
hasDomain() { hasDomain() {
return this.$parent.$parent.activeDomains.length > 0; return this.$parent.$parent.activeDomains.length > 0;
}, },
shareQuery() {
const data = exportData(this.$parent.$parent.activeDomains, this.$parent.$props.data);
return qs.stringify(data, { allowDots: true });
},
shareLink() { shareLink() {
return JSON.stringify(exportData(this.$parent.$parent.activeDomains, this.$parent.$props.data)); const base = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
return `${base}${this.shareQuery.length ? '?' : ''}${this.shareQuery}`;
},
},
watch: {
// When the share link changes, update the site query
shareQuery(query) {
window.history.replaceState({}, '', `?${query}`);
}, },
}, },
methods: { methods: {

View File

@ -29,7 +29,10 @@ export default (domains, global) => {
// Handle domains // Handle domains
// Always save changes, even if none, so we can replicate the correct number of domains // Always save changes, even if none, so we can replicate the correct number of domains
exportData.domains = domains.map(domain => categoriesExport(domain[0])); exportData.domains = domains.map(domain => categoriesExport(domain[0])).reduce((prev, current, index) => {
prev[index] = current;
return prev;
}, {});
// Handle global // Handle global
// If there were any category changes, save global changes // If there were any category changes, save global changes