-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yohan
committed
Nov 9, 2023
1 parent
ea0e63a
commit 718b408
Showing
10 changed files
with
149 additions
and
140 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,4 +141,4 @@ export default { | |
}, | ||
}, | ||
}; | ||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,4 +104,4 @@ export default { | |
}; | ||
</script> | ||
<style></style> | ||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { InlineDefaults, AttributeDefaults } from './moduleDefaults.js' | ||
import { createModule } from "./moduleFactory"; | ||
import { createModule } from "./moduleFactory.js"; | ||
|
||
const Row = function ({ UUID, ADMIN_LABEL }) { | ||
|
||
// We are including a column by default | ||
const column = createModule('Column'); | ||
// We are including a column by default | ||
const column = createModule('Column'); | ||
|
||
this.uuid = `${UUID}` | ||
this.type = 'row' | ||
this.config = { | ||
enabled: true, | ||
buildamic_settings: { | ||
admin_label: ADMIN_LABEL || this.type, | ||
column_count_total: 12, | ||
inline: { ...JSON.parse(JSON.stringify(InlineDefaults)) }, | ||
attributes: { ...JSON.parse(JSON.stringify(AttributeDefaults)) } | ||
} | ||
this.uuid = `${UUID}` | ||
this.type = 'row' | ||
this.config = { | ||
enabled: true, | ||
buildamic_settings: { | ||
admin_label: ADMIN_LABEL || this.type, | ||
column_count_total: 12, | ||
inline: { ...JSON.parse(JSON.stringify(InlineDefaults)) }, | ||
attributes: { ...JSON.parse(JSON.stringify(AttributeDefaults)) } | ||
} | ||
this.value = [column] | ||
} | ||
this.value = [column] | ||
} | ||
|
||
export { Row } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { InlineDefaults, AttributeDefaults } from './moduleDefaults.js' | ||
import { createModule } from "./moduleFactory"; | ||
import { createModule } from "./moduleFactory.js"; | ||
|
||
const Section = function ({ UUID, ADMIN_LABEL }) { | ||
|
||
// Wea | ||
const row = createModule('Row'); | ||
// Wea | ||
const row = createModule('Row'); | ||
|
||
this.uuid = `${UUID}` | ||
this.type = 'section' | ||
this.config = { | ||
enabled: true, | ||
buildamic_settings: { | ||
admin_label: ADMIN_LABEL || this.type, | ||
inline: { ...JSON.parse(JSON.stringify(InlineDefaults)) }, | ||
boxed_layout: true, | ||
attributes: { ...JSON.parse(JSON.stringify(AttributeDefaults)) } | ||
} | ||
this.uuid = `${UUID}` | ||
this.type = 'section' | ||
this.config = { | ||
enabled: true, | ||
buildamic_settings: { | ||
admin_label: ADMIN_LABEL || this.type, | ||
inline: { ...JSON.parse(JSON.stringify(InlineDefaults)) }, | ||
boxed_layout: true, | ||
attributes: { ...JSON.parse(JSON.stringify(AttributeDefaults)) } | ||
} | ||
this.value = [row] | ||
} | ||
this.value = [row] | ||
} | ||
|
||
export { Section } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,106 @@ | ||
import resolveConfig from "tailwindcss/resolveConfig"; | ||
import resolveConfig from "tailwindcss/resolveConfig.js"; | ||
import tailwindConfig from "../../../tailwind.config.js"; | ||
import { InlineDefaults, AttributeDefaults } from '../factories/modules/moduleDefaults'; | ||
import { InlineDefaults, AttributeDefaults } from '../factories/modules/moduleDefaults.js'; | ||
const fullConfig = resolveConfig(tailwindConfig); | ||
import { getDeep, setDeep, mergeDeep } from '../functions/objectHelpers' | ||
import { getDeep, setDeep, mergeDeep } from '../functions/objectHelpers.js' | ||
import { mapGetters, mapActions } from 'vuex' | ||
import { bus } from '../eventBus' | ||
import { bus } from '../eventBus.js' | ||
|
||
const removeXSPrefixFromValue = (value) => { | ||
return value.indexOf(':') === -1 ? value : value.split(':')[1]; | ||
return value.indexOf(':') === -1 ? value : value.split(':')[1]; | ||
} | ||
|
||
export default { | ||
data() { | ||
return { | ||
reactiveTick: 0 | ||
} | ||
data() { | ||
return { | ||
reactiveTick: 0 | ||
} | ||
}, | ||
computed: { | ||
...mapGetters(["breakpoint", "dirtyFields"]), | ||
settings() { | ||
return this.field.config.buildamic_settings | ||
} | ||
}, | ||
created: function () { | ||
this.setDirtyFields([]); | ||
if (this.field) { | ||
// Backwards Compatibility with older versions of the addon | ||
if (!this.settings?.inline || InlineDefaults.version !== this.settings.inline?.version) { | ||
this.setInlineDefaults(); | ||
} | ||
if (!this.settings?.attributes || AttributeDefaults.version !== this.settings.attributes?.version) { | ||
this.setAttributeDefaults(); | ||
} | ||
} | ||
}, | ||
methods: { | ||
...mapActions(['setDirtyFields']), | ||
setDeep, | ||
getDeep(e, obj = this.settings) { | ||
const val = getDeep(obj, e); | ||
return val ? val : false | ||
}, | ||
computed: { | ||
...mapGetters(["breakpoint", "dirtyFields"]), | ||
settings() { | ||
return this.field.config.buildamic_settings | ||
} | ||
saveFields() { | ||
return true | ||
}, | ||
created: function () { | ||
this.setDirtyFields([]); | ||
if (this.field) { | ||
// Backwards Compatibility with older versions of the addon | ||
if (!this.settings?.inline || InlineDefaults.version !== this.settings.inline?.version) { | ||
this.setInlineDefaults(); | ||
} | ||
if (!this.settings?.attributes || AttributeDefaults.version !== this.settings.attributes?.version) { | ||
this.setAttributeDefaults(); | ||
} | ||
} | ||
}, | ||
methods: { | ||
...mapActions(['setDirtyFields']), | ||
setDeep, | ||
getDeep(e, obj = this.settings) { | ||
const val = getDeep(obj, e); | ||
return val ? val : false | ||
}, | ||
saveFields() { | ||
return true | ||
}, | ||
updateField({ obj = this.settings, path, type = null, key = '', val, vm = this }, responsive = false) { | ||
if (type === 'asset' && !val.length) return | ||
const fullPath = responsive ? `${path}.${this.breakpoint}` : path | ||
updateField({ obj = this.settings, path, type = null, key = '', val, vm = this }, responsive = false) { | ||
if (type === 'asset' && !val.length) return | ||
const fullPath = responsive ? `${path}.${this.breakpoint}` : path | ||
|
||
// We have an XS option for responsive sizes but tailwind has no prefix for the smallest size so | ||
// we need to remove xs from the value | ||
if (responsive && typeof val === 'string' && val !== 'none' && val && this.breakpoint === 'xs') { | ||
val = removeXSPrefixFromValue(val); | ||
} | ||
// We have an XS option for responsive sizes but tailwind has no prefix for the smallest size so | ||
// we need to remove xs from the value | ||
if (responsive && typeof val === 'string' && val !== 'none' && val && this.breakpoint === 'xs') { | ||
val = removeXSPrefixFromValue(val); | ||
} | ||
|
||
// When choosing the "none" option in select fields, remove the value | ||
if (val === 'none') { | ||
val = '' | ||
} | ||
// When choosing the "none" option in select fields, remove the value | ||
if (val === 'none') { | ||
val = '' | ||
} | ||
|
||
// Get the fields value when first opening the stack and add that | ||
// to the dirty fields array allowing reverting changes if not saved. | ||
const existingIndex = this.dirtyFields.findIndex(el => el.obj.uuid, obj.uuid); | ||
const oldValue = { obj, fullPath, val: (getDeep(obj, fullPath) ?? '') }; | ||
if (existingIndex === -1) { | ||
this.setDirtyFields([...this.dirtyFields, oldValue]); | ||
} | ||
// Get the fields value when first opening the stack and add that | ||
// to the dirty fields array allowing reverting changes if not saved. | ||
const existingIndex = this.dirtyFields.findIndex(el => el.obj.uuid, obj.uuid); | ||
const oldValue = { obj, fullPath, val: (getDeep(obj, fullPath) ?? '') }; | ||
if (existingIndex === -1) { | ||
this.setDirtyFields([...this.dirtyFields, oldValue]); | ||
} | ||
|
||
// Set the value in pagebuilder JSON and validate the field | ||
setDeep(obj, fullPath, val); | ||
this.$nextTick(() => { | ||
bus.$emit('validate-fields', path.split('.').pop()); | ||
}) | ||
// Set the value in pagebuilder JSON and validate the field | ||
setDeep(obj, fullPath, val); | ||
this.$nextTick(() => { | ||
bus.$emit('validate-fields', path.split('.').pop()); | ||
}) | ||
|
||
this.reactiveTick++; | ||
}, | ||
updateMeta({ obj = this.settings, path, val }, responsive = false) { | ||
const fullPath = responsive ? `${path}.${this.breakpoint}` : path | ||
if (fullPath) { | ||
setDeep(obj, fullPath, val); | ||
} | ||
}, | ||
getTWClasses(type, prefix) { | ||
const options = Object.entries(fullConfig.theme[type]).reduce( | ||
(acc, [key, val]) => { | ||
if (key.charAt(0) !== '-') { | ||
acc[`${prefix}-${key}`] = `${prefix}-${key}`; | ||
} else { | ||
acc[`-${prefix}${key}`] = `-${prefix}${key}`; | ||
} | ||
return acc; | ||
}, | ||
{} | ||
); | ||
return Object.assign({ 'none': 'N/A' }, options); | ||
}, | ||
setInlineDefaults() { | ||
this.setDeep(this.settings, 'inline', mergeDeep(JSON.parse(JSON.stringify(InlineDefaults)), (this.settings?.inline || {}))); | ||
this.reactiveTick++; | ||
}, | ||
updateMeta({ obj = this.settings, path, val }, responsive = false) { | ||
const fullPath = responsive ? `${path}.${this.breakpoint}` : path | ||
if (fullPath) { | ||
setDeep(obj, fullPath, val); | ||
} | ||
}, | ||
getTWClasses(type, prefix) { | ||
const options = Object.entries(fullConfig.theme[type]).reduce( | ||
(acc, [key, val]) => { | ||
if (key.charAt(0) !== '-') { | ||
acc[`${prefix}-${key}`] = `${prefix}-${key}`; | ||
} else { | ||
acc[`-${prefix}${key}`] = `-${prefix}${key}`; | ||
} | ||
return acc; | ||
}, | ||
setAttributeDefaults() { | ||
this.setDeep(this.settings, 'attributes', mergeDeep(JSON.parse(JSON.stringify(AttributeDefaults)), (this.settings?.attributes || {}))); | ||
} | ||
{} | ||
); | ||
return Object.assign({ 'none': 'N/A' }, options); | ||
}, | ||
setInlineDefaults() { | ||
this.setDeep(this.settings, 'inline', mergeDeep(JSON.parse(JSON.stringify(InlineDefaults)), (this.settings?.inline || {}))); | ||
}, | ||
setAttributeDefaults() { | ||
this.setDeep(this.settings, 'attributes', mergeDeep(JSON.parse(JSON.stringify(AttributeDefaults)), (this.settings?.attributes || {}))); | ||
} | ||
}, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters