diff --git a/src/store/config/index.js b/src/store/config/index.js index d76670c5..98e448b5 100644 --- a/src/store/config/index.js +++ b/src/store/config/index.js @@ -535,16 +535,16 @@ export default { ...getters.queryString }; - let dots = ''; - - for (let i = 0; i < state.path.split('/').length; i++) { - dots += '../'; - } - if (forTest) { // when run as part of a test, fix path since rule will be in server_data/tests/ config.import = '../../rules/BaseRule.config'; } else { + let dots = ''; + + for (let i = 1; i < state.path.split('/').length; i++) { + dots += '../'; + } + config.import = `${dots}BaseRule.config`; } diff --git a/src/store/configs.js b/src/store/configs.js index 02786df1..5a5e22c4 100644 --- a/src/store/configs.js +++ b/src/store/configs.js @@ -135,10 +135,20 @@ export default { let newConfig = cloneDeep(oldConfig); // If there is a new path (i.e. in a subfolder), add that to the full pathname - newConfig.__praeco_full_path = `${newPath ? `${newPath}/` : ''}${newConfig.name}`; + newConfig.__praeco_full_path = `${newPath}${newConfig.name}`; if (oldConfig.__praeco_full_path === newConfig.__praeco_full_path) return; + if (type === 'rules') { + let dots = ''; + + for (let i = 1; i < newConfig.__praeco_full_path.split('/').length; i++) { + dots += '../'; + } + + newConfig.import = `${dots}BaseRule.config`; + } + try { // Create the config at the full path let res = await dispatch('createConfig', { config: newConfig, type });