Skip to content

Commit

Permalink
Fix config-post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkykh committed Sep 8, 2018
1 parent 6424ec4 commit cfbe144
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
15 changes: 12 additions & 3 deletions themes-default/slim/src/components/config-post-processing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<span>Sync File Extensions</span>
</label>
<div class="col-sm-10 content">
<select-list name="sync_files" id="sync_files" csv-enabled :list-items="postProcessing.syncFiles" @change="postProcessing.syncFiles = $event"></select-list>
<select-list name="sync_files" id="sync_files" csv-enabled :list-items="postProcessing.syncFiles" @change="onChangeSyncFiles"></select-list>
<span>comma seperated list of extensions or filename globs Medusa ignores when Post Processing</span>
</div>
</div>
Expand Down Expand Up @@ -154,7 +154,7 @@
<span>Keep associated file extensions</span>
</label>
<div class="col-sm-10 content">
<select-list name="allowed_extensions" id="allowed_extensions" csv-enabled :list-items="postProcessing.allowedExtensions" @change="postProcessing.allowedExtensions = $event"></select-list>
<select-list name="allowed_extensions" id="allowed_extensions" csv-enabled :list-items="postProcessing.allowedExtensions" @change="onChangeAllowedExtensions"></select-list>
<span>Comma seperated list of associated file extensions Medusa should keep while post processing.</span><br>
<span>Leaving it empty means all associated files will be deleted</span>
</div>
Expand Down Expand Up @@ -229,7 +229,7 @@
<span>Extra Scripts</span>
</label>
<div class="col-sm-10 content">
<select-list name="extra_scripts" id="extra_scripts" csv-enabled :list-items="postProcessing.extraScripts" @change="postProcessing.extraScripts = $event"></select-list>
<select-list name="extra_scripts" id="extra_scripts" csv-enabled :list-items="postProcessing.extraScripts" @change="onChangeExtraScripts"></select-list>
<span>See <app-link :href="postProcessing.extraScriptsUrl" class="wikie"><strong>Wiki</strong></app-link> for script arguments description and usage.</span>
</div>
</div>
Expand Down Expand Up @@ -433,6 +433,15 @@ export default {
};
},
methods: {
onChangeSyncFiles(items) {
this.postProcessing.syncFiles = items.map(item => item.value);
},
onChangeAllowedExtensions(items) {
this.postProcessing.allowedExtensions = items.map(item => item.value);
},
onChangeExtraScripts(items) {
this.postProcessing.extraScripts = items.map(item => item.value);
},
saveNaming(values) {
if (!this.configLoaded) {
return;
Expand Down
21 changes: 10 additions & 11 deletions themes-default/slim/src/components/select-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default {
},
data() {
return {
lock: false,
editItems: [],
newItem: '',
indexCounter: 0,
Expand All @@ -66,17 +65,13 @@ export default {
created() {
/**
* ListItems property might receive values originating from the API,
* that are sometimes not avaiable when rendering.
* @TODO: Maybe we can remove this in the future.
* that are sometimes not available when rendering.
* @TODO: This is not ideal! Maybe we can remove this in the future.
*/
const unwatchProp = this.$watch('listItems', () => {
unwatchProp();
this.lock = true;
this.editItems = this.sanitize(this.listItems);
this.$nextTick(() => {
this.lock = false;
});
this.csv = this.editItems.map(x => x.value).join(', ');
});
},
Expand Down Expand Up @@ -115,6 +110,12 @@ export default {
return values.map((value, index) => {
if (typeof (value) === 'string') {
// Due to a bug introduced in v0.2.9, the value might be a string representing a Python dict.
if (value.startsWith('{') && value.endsWith('}')) {

This comment has been minimized.

Copy link
@p0psicles

p0psicles Sep 9, 2018

Contributor

Are we going to remove this in a couple of versions? Alternatively we can handle this in backend?

This comment has been minimized.

Copy link
@sharkykh

sharkykh Sep 9, 2018

Author Contributor

Are we going to remove this in a couple of versions?

Yeah, I think so.

Alternatively we can handle this in backend?

I thought about doing this on the backend (it probably would have been easier with ast.literal_eval).
But... actually I'm not exactly sure why I went with Frontend-only solution 🤔
Should I change that then?

This comment has been minimized.

Copy link
@OmgImAlexis

OmgImAlexis Sep 9, 2018

Collaborator

@sharkykh we should try and keep as much data manipulation on the backend as possible. Frontend should mainly be for displaying data.

// Get the value: `{u'id': 0, u'value': u'!sync'}` => `!sync`
value = value.match(/u?'value': u?'(.+)'/)[1].replace(`\\'`, `'`);
}
return {
id: index,
value
Expand All @@ -138,7 +139,7 @@ export default {
}
}));
} else {
this.csv = this.editItems.map(x => x.value).join(', ');
this.csv = this.editItems.map(item => item.value).join(', ');
}
},
/**
Expand All @@ -154,9 +155,7 @@ export default {
watch: {
editItems: {
handler() {
if (!this.lock) {
this.$emit('change', this.editItems);
}
this.$emit('change', this.editItems);
},
deep: true
},
Expand Down
Loading

0 comments on commit cfbe144

Please sign in to comment.