Update BaseComponent
parent
6cd41325d1
commit
ea887fcea3
|
@ -10,11 +10,16 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getPTItem(obj = {}, key = '') {
|
||||||
|
const fKey = ObjectUtils.convertToFlatCase(key);
|
||||||
|
|
||||||
|
return obj[Object.keys(obj).find((k) => ObjectUtils.convertToFlatCase(k) === fKey) || ''];
|
||||||
|
},
|
||||||
ptm(key = '', params = {}) {
|
ptm(key = '', params = {}) {
|
||||||
return ObjectUtils.getItemValue((this.pt || {})[key.toLowerCase()], { props: this.$props, state: this.$data, ...params });
|
return ObjectUtils.getItemValue(this.getPTItem(this.pt, key), { props: this.$props, state: this.$data, ...params });
|
||||||
},
|
},
|
||||||
ptmo(obj = {}, key = '', params = {}) {
|
ptmo(obj = {}, key = '', params = {}) {
|
||||||
return ObjectUtils.getItemValue(obj[key.toLowerCase()], params);
|
return ObjectUtils.getItemValue(this.getPTItem(obj, key), params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -205,6 +205,11 @@ export default {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
convertToFlatCase(str) {
|
||||||
|
// convert snake, kebab, camel and pascal cases to flat case
|
||||||
|
return this.isNotEmpty(str) ? str.replace(/(-|_)/g, '').toLowerCase() : str;
|
||||||
|
},
|
||||||
|
|
||||||
isEmpty(value) {
|
isEmpty(value) {
|
||||||
return value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0) || (!(value instanceof Date) && typeof value === 'object' && Object.keys(value).length === 0);
|
return value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0) || (!(value instanceof Date) && typeof value === 'object' && Object.keys(value).length === 0);
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,6 +68,7 @@ export declare class ObjectUtils {
|
||||||
static contains(value: any, list: any[]): boolean;
|
static contains(value: any, list: any[]): boolean;
|
||||||
static insertIntoOrderedArray(item: any, index: number, arr: any[], sourceArr: any[]): void;
|
static insertIntoOrderedArray(item: any, index: number, arr: any[], sourceArr: any[]): void;
|
||||||
static removeAccents(str: any): string;
|
static removeAccents(str: any): string;
|
||||||
|
static convertToFlatCase(str: string): string;
|
||||||
static isEmpty(value: any): boolean;
|
static isEmpty(value: any): boolean;
|
||||||
static isNotEmpty(value: any): boolean;
|
static isNotEmpty(value: any): boolean;
|
||||||
static isPrintableCharacter(char: string): boolean;
|
static isPrintableCharacter(char: string): boolean;
|
||||||
|
|
Loading…
Reference in New Issue