Refactor #4384
parent
e49179be34
commit
57ce4e0183
|
@ -470,7 +470,7 @@ export default {
|
||||||
const searchOut = /./g.test(key) && !!params[key.split('.')[0]];
|
const searchOut = /./g.test(key) && !!params[key.split('.')[0]];
|
||||||
const { mergeSections = true, mergeProps: useMergeProps = false } = this.ptOptions || {};
|
const { mergeSections = true, mergeProps: useMergeProps = false } = this.ptOptions || {};
|
||||||
const global = searchInDefaultPT ? (searchOut ? this._useGlobalPT(this._getPTClassValue, key, params) : this._useDefaultPT(this._getPTClassValue, key, params)) : undefined;
|
const global = searchInDefaultPT ? (searchOut ? this._useGlobalPT(this._getPTClassValue, key, params) : this._useDefaultPT(this._getPTClassValue, key, params)) : undefined;
|
||||||
const self = searchOut ? undefined : this._usePT(this._getPT(obj, this.$name), this._getPTClassValue, key, { ...params, global });
|
const self = searchOut ? undefined : this._usePT(this._getPT(obj, this.$name), this._getPTClassValue, key, { ...params, global: global || {} });
|
||||||
const datasets = key !== 'transition' && {
|
const datasets = key !== 'transition' && {
|
||||||
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.toFlatCase(this.$.type.name) }),
|
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.toFlatCase(this.$.type.name) }),
|
||||||
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
||||||
|
@ -486,12 +486,12 @@ export default {
|
||||||
_getPT(pt, key = '', callback) {
|
_getPT(pt, key = '', callback) {
|
||||||
const _usept = pt?.['_usept'];
|
const _usept = pt?.['_usept'];
|
||||||
|
|
||||||
const getValue = (value) => {
|
const getValue = (value, checkSameKey = false) => {
|
||||||
const computedValue = callback ? callback(value) : value;
|
const computedValue = callback ? callback(value) : value;
|
||||||
const _key = ObjectUtils.toFlatCase(key);
|
const _key = ObjectUtils.toFlatCase(key);
|
||||||
const _cKey = ObjectUtils.toFlatCase(this.$name);
|
const _cKey = ObjectUtils.toFlatCase(this.$name);
|
||||||
|
|
||||||
return (_key !== _cKey ? computedValue?.[_key] : undefined) ?? computedValue;
|
return (checkSameKey ? (_key !== _cKey ? computedValue?.[_key] : undefined) : computedValue?.[_key]) ?? computedValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
return ObjectUtils.isNotEmpty(_usept)
|
return ObjectUtils.isNotEmpty(_usept)
|
||||||
|
@ -500,13 +500,13 @@ export default {
|
||||||
originalValue: getValue(pt.originalValue),
|
originalValue: getValue(pt.originalValue),
|
||||||
value: getValue(pt.value)
|
value: getValue(pt.value)
|
||||||
}
|
}
|
||||||
: getValue(pt);
|
: getValue(pt, true);
|
||||||
},
|
},
|
||||||
_usePT(pt, callback, key, params) {
|
_usePT(pt, callback, key, params) {
|
||||||
const fn = (value) => callback(value, key, params);
|
const fn = (value) => callback(value, key, params);
|
||||||
|
|
||||||
if (pt?.hasOwnProperty('_usept')) {
|
if (pt?.hasOwnProperty('_usept')) {
|
||||||
const { mergeSections = true, mergeProps: useMergeProps = false } = this.ptOptions || pt['_usept'] || {};
|
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || {};
|
||||||
const originalValue = fn(pt.originalValue);
|
const originalValue = fn(pt.originalValue);
|
||||||
const value = fn(pt.value);
|
const value = fn(pt.value);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ const BaseDirective = {
|
||||||
const datasetPrefix = 'data-pc-';
|
const datasetPrefix = 'data-pc-';
|
||||||
const { mergeSections = true, mergeProps: useMergeProps = false } = instance.binding?.value?.ptOptions || {};
|
const { mergeSections = true, mergeProps: useMergeProps = false } = instance.binding?.value?.ptOptions || {};
|
||||||
const global = searchInDefaultPT ? BaseDirective._useDefaultPT(instance, instance.defaultPT, getValue, key, params) : undefined;
|
const global = searchInDefaultPT ? BaseDirective._useDefaultPT(instance, instance.defaultPT, getValue, key, params) : undefined;
|
||||||
const self = BaseDirective._usePT(instance, BaseDirective._getPT(obj, instance.$name), getValue, key, { ...params, global });
|
const self = BaseDirective._usePT(instance, BaseDirective._getPT(obj, instance.$name), getValue, key, { ...params, global: global || {} });
|
||||||
const datasets = {
|
const datasets = {
|
||||||
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.toFlatCase(instance.$name) }),
|
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.toFlatCase(instance.$name) }),
|
||||||
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
||||||
|
@ -37,8 +37,9 @@ const BaseDirective = {
|
||||||
|
|
||||||
const getValue = (value) => {
|
const getValue = (value) => {
|
||||||
const computedValue = callback ? callback(value) : value;
|
const computedValue = callback ? callback(value) : value;
|
||||||
|
const _key = ObjectUtils.toFlatCase(key);
|
||||||
|
|
||||||
return computedValue?.[ObjectUtils.toFlatCase(key)] ?? computedValue;
|
return computedValue?.[_key] ?? computedValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
return ObjectUtils.isNotEmpty(_usept)
|
return ObjectUtils.isNotEmpty(_usept)
|
||||||
|
@ -53,7 +54,7 @@ const BaseDirective = {
|
||||||
const fn = (value) => callback(value, key, params);
|
const fn = (value) => callback(value, key, params);
|
||||||
|
|
||||||
if (pt?.hasOwnProperty('_usept')) {
|
if (pt?.hasOwnProperty('_usept')) {
|
||||||
const { mergeSections = true, mergeProps: useMergeProps = false } = instance.binding?.value?.ptOptions || pt['_usept'] || {};
|
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || {};
|
||||||
const originalValue = fn(pt.originalValue);
|
const originalValue = fn(pt.originalValue);
|
||||||
const value = fn(pt.value);
|
const value = fn(pt.value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue