Add all the logic for presets working
This commit is contained in:
parent
1df3ab88f6
commit
043f89eac0
|
@ -61,6 +61,12 @@ limitations under the License.
|
||||||
if (changes) return ` (${changes.toLocaleString()})`;
|
if (changes) return ` (${changes.toLocaleString()})`;
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
setValue(tab, key, val) {
|
||||||
|
Object.assign(this.$props.data[tab][key], { value: val, computed: val });
|
||||||
|
},
|
||||||
|
resetValue(tab, key) {
|
||||||
|
this.setValue(tab, key, this.$props.data[tab][key].default);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div>Hello world presets</div>
|
<div>
|
||||||
|
<a v-for="(preset, key) in $props.data"
|
||||||
|
:class="`button${preset.computed ? ' is-primary' : ''}`"
|
||||||
|
@click="setPreset(key)"
|
||||||
|
>
|
||||||
|
{{ preset.display }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -10,34 +17,42 @@
|
||||||
const defaults = {
|
const defaults = {
|
||||||
frontend: {
|
frontend: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Frontend',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
default: true,
|
default: true,
|
||||||
|
display: 'PHP',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
django: {
|
django: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Django',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
nodejs: {
|
nodejs: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Node.js',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
singlePageApplication: {
|
singlePageApplication: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Single-page application',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
wordPress: {
|
wordPress: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'WordPress',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
drupal: {
|
drupal: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Drupal',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
magento: {
|
magento: {
|
||||||
default: false,
|
default: false,
|
||||||
|
display: 'Magento',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -56,5 +71,65 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: computedFromDefaults(defaults), // Getters & setters for the delegated data
|
computed: computedFromDefaults(defaults), // Getters & setters for the delegated data
|
||||||
|
methods: {
|
||||||
|
setPreset(key) {
|
||||||
|
// Set that we're using this preset
|
||||||
|
Object.keys(this.$props.data).forEach(preset => this[preset] = preset === key);
|
||||||
|
|
||||||
|
// Restore some specific defaults first
|
||||||
|
this.$parent.resetValue('server', 'domain');
|
||||||
|
this.$parent.resetValue('php', 'php');
|
||||||
|
this.$parent.resetValue('php', 'wordPressRules');
|
||||||
|
this.$parent.resetValue('php', 'drupalRules');
|
||||||
|
this.$parent.resetValue('php', 'magentoRules');
|
||||||
|
this.$parent.resetValue('python', 'python');
|
||||||
|
this.$parent.resetValue('python', 'djangoRules');
|
||||||
|
this.$parent.resetValue('reverseProxy', 'reverseProxy');
|
||||||
|
this.$parent.resetValue('routing', 'root');
|
||||||
|
this.$parent.resetValue('routing', 'index');
|
||||||
|
this.$parent.resetValue('routing', 'fallbackHtml');
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 'frontend':
|
||||||
|
this.$parent.setValue('php', 'php', false);
|
||||||
|
this.$parent.setValue('routing', 'index', 'index.html');
|
||||||
|
this.$parent.setValue('routing', 'fallbackHtml', true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'php':
|
||||||
|
this.$parent.setValue('routing', 'index', 'index.php');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'django':
|
||||||
|
this.$parent.setValue('php', 'php', false);
|
||||||
|
this.$parent.setValue('python', 'python', true);
|
||||||
|
this.$parent.setValue('python', 'djangoRules', true);
|
||||||
|
this.$parent.setValue('routing', 'root', false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'nodejs':
|
||||||
|
this.$parent.setValue('reverseProxy', 'reverseProxy', true);
|
||||||
|
this.$parent.setValue('routing', 'root', false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'singlePageApplication':
|
||||||
|
this.$parent.setValue('routing', 'index', 'index.html');
|
||||||
|
this.$parent.setValue('routing', 'fallbackHtml', true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'wordPress':
|
||||||
|
this.$parent.setValue('php', 'wordPressRules', true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'drupal':
|
||||||
|
this.$parent.setValue('php', 'drupalRules', true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'magento':
|
||||||
|
this.$parent.setValue('php', 'magentoRules', true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
options: ['index.html', 'index.php'],
|
options: ['index.html', 'index.php'],
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
fallbackRouting: {
|
fallbackHtml: {
|
||||||
default: ['index.php'],
|
default: false,
|
||||||
options: ['index.html', 'index.php'],
|
enabled: true,
|
||||||
|
},
|
||||||
|
fallbackPhp: {
|
||||||
|
default: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
legacyPhpRouting: {
|
legacyPhpRouting: {
|
||||||
|
|
Loading…
Reference in New Issue