diff --git a/ABFactoryCore.js b/ABFactoryCore.js index cb3cbbd..fffa65d 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -35,7 +35,6 @@ const ABProcessLane = require("../platform/process/ABProcessLane"); const ABProcessTaskManager = require("./process/ABProcessTaskManager"); const ABStep = require("../platform/ABStep"); -const ABViewDetailItem = require("../platform/views/ABViewDetailItem"); const ABMobileViewFormItem = require("../platform/mobile/ABMobileViewFormItem"); // const ABObjectWorkspaceViewGrid = require("../platform/workspaceViews/ABObjectWorkspaceViewGrid"); @@ -125,7 +124,6 @@ class ABFactory extends EventEmitter { ABProcessTaskManager, - ABViewDetailItem, ABMobileViewFormItem, }; diff --git a/ABViewManagerCore.js b/ABViewManagerCore.js index 676533a..9bfba43 100644 --- a/ABViewManagerCore.js +++ b/ABViewManagerCore.js @@ -46,14 +46,14 @@ var AllViews = [ // // Detail Components // - require("../platform/views/ABViewDetail"), - require("../platform/views/ABViewDetailCheckbox"), - require("../platform/views/ABViewDetailConnect"), - require("../platform/views/ABViewDetailCustom"), - require("../platform/views/ABViewDetailImage"), + // require("../platform/views/ABViewDetail"), + // require("../platform/views/ABViewDetailCheckbox"), + // require("../platform/views/ABViewDetailConnect"), + // require("../platform/views/ABViewDetailCustom"), + // require("../platform/views/ABViewDetailImage"), // require("../platform/views/ABViewDetailSelectivity"), - require("../platform/views/ABViewDetailText"), - require("../platform/views/ABViewDetailTree"), + // require("../platform/views/ABViewDetailText"), + // require("../platform/views/ABViewDetailTree"), ]; /* diff --git a/views/ABViewCarouselCore.js b/views/ABViewCarouselCore.js deleted file mode 100644 index 16b325f..0000000 --- a/views/ABViewCarouselCore.js +++ /dev/null @@ -1,102 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewCarouselPropertyComponentDefaults = { - dataviewID: null, // uuid of ABDatacollection - field: null, // uuid - - width: 460, - height: 275, - showLabel: true, - hideItem: false, - hideButton: false, - navigationType: "corner", // "corner" || "side" - filterByCursor: false, - - detailsPage: null, // uuid - detailsTab: null, // uuid - editPage: null, // uuid - editTab: null, // uuid -}; - -const ABViewDefaults = { - key: "carousel", // {string} unique key for this view - icon: "clone", // {string} fa-[icon] reference for this view - labelKey: "Carousel", // {string} the multilingual label key for the class label -}; - -function parseIntOrDefault(_this, key) { - if (typeof _this.settings[key] != "undefined") { - _this.settings[key] = parseInt(_this.settings[key]); - } else { - _this.settings[key] = ABViewCarouselPropertyComponentDefaults[key]; - } -} - -function parseOrDefault(_this, key) { - try { - _this.settings[key] = JSON.parse(_this.settings[key]); - } catch (e) { - _this.settings[key] = ABViewCarouselPropertyComponentDefaults[key]; - } -} - -module.exports = class ABViewCarouselCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewCarouselPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - parseIntOrDefault(this, "width"); - parseIntOrDefault(this, "height"); - - // json - parseOrDefault(this, "showLabel"); - parseOrDefault(this, "hideItem"); - parseOrDefault(this, "hideButton"); - - this.settings.navigationType = - this.settings.navigationType || - ABViewCarouselPropertyComponentDefaults.navigationType; - - parseOrDefault(this, "filterByCursor"); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - get imageField() { - let dc = this.datacollection; - if (!dc) return null; - - let obj = dc.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.field); - } -}; diff --git a/views/ABViewChartAreaCore.js b/views/ABViewChartAreaCore.js deleted file mode 100644 index 31e7397..0000000 --- a/views/ABViewChartAreaCore.js +++ /dev/null @@ -1,83 +0,0 @@ -const ABViewChartContainer = require("../../platform/views/ABViewChartContainer"); - -const ABViewChartAreaPropertyComponentDefaults = { - areaType: "area", - isLegend: 1, - // chartWidth: 600, - chartHeight: 200, - labelFontSize: 12, - stepValue: 20, - maxValue: 100, -}; - -const ABViewDefaults = { - key: "area", // {string} unique key for this view - icon: "area-chart", // {string} fa-[icon] reference for this view - labelKey: "Area", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewChartAreaCore extends ABViewChartContainer { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewChartAreaPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.areaType = - this.settings.areaType || - ABViewChartAreaPropertyComponentDefaults.areaType; - - this.settings.isLegend = parseInt( - this.settings.isLegend ?? - ABViewChartAreaPropertyComponentDefaults.isLegend - ); - - // this.settings.chartWidth = parseInt(this.settings.chartWidth || ABViewChartAreaPropertyComponentDefaults.chartWidth); - this.settings.chartHeight = parseInt( - this.settings.chartHeight ?? - ABViewChartAreaPropertyComponentDefaults.chartHeight - ); - - this.settings.labelFontSize = parseInt( - this.settings.labelFontSize ?? - ABViewChartAreaPropertyComponentDefaults.labelFontSize - ); - this.settings.stepValue = parseInt( - this.settings.stepValue ?? - ABViewChartAreaPropertyComponentDefaults.stepValue - ); - this.settings.maxValue = parseInt( - this.settings.maxValue ?? - ABViewChartAreaPropertyComponentDefaults.maxValue - ); - - this.translate(this, this, ["areaLabel"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewChartBarCore.js b/views/ABViewChartBarCore.js deleted file mode 100644 index 2636666..0000000 --- a/views/ABViewChartBarCore.js +++ /dev/null @@ -1,87 +0,0 @@ -const ABViewChartContainer = require("../../platform/views/ABViewChartContainer"); - -const ABViewChartBarPropertyComponentDefaults = { - barType: "bar", - barPreset: "column", - isLegend: 1, - // chartWidth: 600, - height: 200, - labelFontSize: 12, - stepValue: 20, - maxValue: 100, -}; - -const ABViewDefaults = { - key: "bar", // {string} unique key for this view - icon: "bar-chart", // {string} fa-[icon] reference for this view - labelKey: "Bar", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewChartBarCore extends ABViewChartContainer { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewChartBarPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.barType = - this.settings.barType || - ABViewChartBarPropertyComponentDefaults.barType; - - this.settings.barPreset = - this.settings.barPreset || - ABViewChartBarPropertyComponentDefaults.barPreset; - - this.settings.isLegend = parseInt( - this.settings.isLegend ?? - ABViewChartBarPropertyComponentDefaults.isLegend - ); - - // this.settings.chartWidth = parseInt(this.settings.chartWidth || ABViewChartBarPropertyComponentDefaults.chartWidth); - this.settings.height = parseInt( - this.settings.height ?? ABViewChartBarPropertyComponentDefaults.height - ); - - this.settings.labelFontSize = parseInt( - this.settings.labelFontSize ?? - ABViewChartBarPropertyComponentDefaults.labelFontSize - ); - this.settings.stepValue = parseInt( - this.settings.stepValue ?? - ABViewChartBarPropertyComponentDefaults.stepValue - ); - this.settings.maxValue = parseInt( - this.settings.maxValue ?? - ABViewChartBarPropertyComponentDefaults.maxValue - ); - - this.translate(this, this, ["barLabel"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewChartCore.js b/views/ABViewChartCore.js deleted file mode 100644 index 9a000e2..0000000 --- a/views/ABViewChartCore.js +++ /dev/null @@ -1,135 +0,0 @@ -const ABViewContainer = require("../../platform/views/ABViewContainer"); - -const ABViewChartPropertyComponentDefaults = { - dataviewID: "", - columnValue: "", - columnLabel: "", - columnValue2: "", - isPercentage: 1, - showLabel: 1, - labelPosition: "left", - labelWidth: 120, - height: 200, - multipleSeries: 0, -}; - -const ABViewChartDefaults = { - key: "chart", // {string} unique key for this view - icon: "bar-chart", // {string} fa-[icon] reference for this view - labelKey: "Chart", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewChartCore extends ABViewContainer { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewChartDefaults); - } - - static common() { - return ABViewChartDefaults; - } - - static defaultValues() { - return ABViewChartPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.dataviewID = - this.settings.dataviewID ?? - ABViewChartPropertyComponentDefaults.dataviewID; - - this.settings.columnValue = - this.settings.columnValue ?? - ABViewChartPropertyComponentDefaults.columnValue; - - this.settings.columnLabel = - this.settings.columnLabel ?? - ABViewChartPropertyComponentDefaults.columnLabel; - - this.settings.columnValue2 = - this.settings.columnValue2 ?? - ABViewChartPropertyComponentDefaults.columnValue2; - - this.settings.isPercentage = parseInt( - this.settings.isPercentage ?? - ABViewChartPropertyComponentDefaults.isPercentage - ); - - this.settings.showLabel = parseInt( - this.settings.showLabel ?? - ABViewChartPropertyComponentDefaults.showLabel - ); - - this.settings.labelPosition = - this.settings.labelPosition || - ABViewChartPropertyComponentDefaults.labelPosition; - - this.settings.labelWidth = parseInt( - this.settings.labelWidth ?? - ABViewChartPropertyComponentDefaults.labelWidth - ); - - this.settings.height = parseInt( - this.settings.height ?? ABViewChartPropertyComponentDefaults.height - ); - - this.settings.multipleSeries = parseInt( - this.settings.multipleSeries ?? - ABViewChartPropertyComponentDefaults.multipleSeries - ); - - this.translate(this, this, ["chartLabel"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - const viewsToAllow = ["label", "pie", "bar", "line", "area"]; - return this.application.viewAll((c) => { - return viewsToAllow.indexOf(c.common().key) > -1; - }); - } - - labelField() { - const dc = this.datacollection; - if (!dc) return null; - - const obj = dc.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnLabel); - } - - valueField() { - const dc = this.datacollection; - if (!dc) return null; - - const obj = dc.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnValue); - } - - valueField2() { - const dc = this.datacollection; - if (!dc) return null; - - const obj = dc.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnValue2); - } -}; diff --git a/views/ABViewChartLineCore.js b/views/ABViewChartLineCore.js deleted file mode 100644 index 0bf8121..0000000 --- a/views/ABViewChartLineCore.js +++ /dev/null @@ -1,88 +0,0 @@ -const ABViewChartContainer = require("../../platform/views/ABViewChartContainer"); - -const ABViewChartLinePropertyComponentDefaults = { - lineType: "line", - linePreset: "plot", - isLegend: 1, - // chartWidth: 600, - chartHeight: 200, - labelFontSize: 12, - stepValue: 20, - maxValue: 100, -}; - -const ABViewDefaults = { - key: "line", // {string} unique key for this view - icon: "line-chart", // {string} fa-[icon] reference for this view - labelKey: "Line", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewChartLineCore extends ABViewChartContainer { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewChartLinePropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.lineType = - this.settings.lineType || - ABViewChartLinePropertyComponentDefaults.lineType; - - this.settings.linePreset = - this.settings.linePreset || - ABViewChartLinePropertyComponentDefaults.linePreset; - - this.settings.isLegend = parseInt( - this.settings.isLegend ?? - ABViewChartLinePropertyComponentDefaults.isLegend - ); - - // this.settings.chartWidth = parseInt(this.settings.chartWidth || ABViewChartLinePropertyComponentDefaults.chartWidth); - this.settings.chartHeight = parseInt( - this.settings.chartHeight ?? - ABViewChartLinePropertyComponentDefaults.chartHeight - ); - - this.settings.labelFontSize = parseInt( - this.settings.labelFontSize ?? - ABViewChartLinePropertyComponentDefaults.labelFontSize - ); - this.settings.stepValue = parseInt( - this.settings.stepValue ?? - ABViewChartLinePropertyComponentDefaults.stepValue - ); - this.settings.maxValue = parseInt( - this.settings.maxValue ?? - ABViewChartLinePropertyComponentDefaults.maxValue - ); - - this.translate(this, this, ["lineLabel"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewChartPieCore.js b/views/ABViewChartPieCore.js deleted file mode 100644 index b19d1e7..0000000 --- a/views/ABViewChartPieCore.js +++ /dev/null @@ -1,77 +0,0 @@ -const ABViewChartContainer = require("../../platform/views/ABViewChartContainer"); - -const ABViewChartPiePropertyComponentDefaults = { - pieType: "pie", - isLegend: 1, - // chartWidth: 600, - height: 200, - innerFontSize: 12, - labelFontSize: 12, -}; - -const ABViewDefaults = { - key: "pie", // {string} unique key for this view - icon: "pie-chart", // {string} fa-[icon] reference for this view - labelKey: "Pie", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewChartPieCore extends ABViewChartContainer { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewChartPiePropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.pieType = - this.settings.pieType || - ABViewChartPiePropertyComponentDefaults.pieType; - - this.settings.isLegend = parseInt( - this.settings.isLegend ?? - ABViewChartPiePropertyComponentDefaults.isLegend - ); - - // this.settings.chartWidth = parseInt(this.settings.chartWidth || ABViewChartPiePropertyComponentDefaults.chartWidth); - this.settings.height = parseInt( - this.settings.height ?? ABViewChartPiePropertyComponentDefaults.height - ); - - this.settings.innerFontSize = parseInt( - this.settings.innerFontSize ?? - ABViewChartPiePropertyComponentDefaults.innerFontSize - ); - this.settings.labelFontSize = parseInt( - this.settings.labelFontSize ?? - ABViewChartPiePropertyComponentDefaults.labelFontSize - ); - - this.translate(this, this, ["pieLabel"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewCommentCore.js b/views/ABViewCommentCore.js deleted file mode 100644 index 36c1b0f..0000000 --- a/views/ABViewCommentCore.js +++ /dev/null @@ -1,140 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewCommentPropertyComponentDefaults = { - dataviewID: null, - columnUser: null, - columnComment: null, - columnDate: null, - height: 300, - label: "", // label is required and you can add more if the component needs them - // format:0 // 0 - normal, 1 - title, 2 - description -}; - -const ABViewDefaults = { - key: "comment", // {string} unique key for this view - icon: "comments", // {string} fa-[icon] reference for this view - labelKey: "Comment", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewCommentCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewCommentPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - // this.settings.format = parseInt(this.settings.format); - // if this is being instantiated on a read from the Property UI, - this.settings.height = parseInt(this.settings.height || 0); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - getCurrentUserId() { - const userObject = this.getUsers(); - const currentUser = this.AB.Account.username(); - //Anonymous User = 0 - - if (!userObject) return; - - return userObject.findIndex((e) => e.value === currentUser) + 1; - } - - getUsers() { - return this.AB.Account.userList().map((e) => { - return { - id: e.username, - value: e.username, - image: e.image_id, - }; - }); - } - - getUserField() { - var dv = this.datacollection; - if (!dv) return null; - - var obj = dv.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnUser); - } - - getCommentField() { - var dv = this.datacollection; - if (!dv) return null; - - var obj = dv.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnComment); - } - - getDateField() { - var dv = this.datacollection; - if (!dv) return null; - - var obj = dv.datasource; - if (!obj) return null; - - return obj.fieldByID(this.settings.columnDate); - } - - getUserData() { - let UserImageField = this.AB.objectUser().fieldByID( - "6383ce19-b344-44ee-87e6-decced7361f8" - ); - - var userObject = this.getUsers(); - var userList = []; - - if (!userObject) return; - - userObject.forEach((item, index) => { - var imageURL = ""; - if (item.image) { - imageURL = UserImageField.urlImage(item.image); - } - var user = { id: index + 1, value: item.value, image: imageURL }; - userList.push(user); - }); - return userList; - } - - model() { - let dv = this.datacollection; - if (!dv) return null; // TODO: refactor in v2 - - // get ABModel - let model = dv.model; // already notified - if (!model) return null; - - return model; - } -}; diff --git a/views/ABViewDataSelectCore.js b/views/ABViewDataSelectCore.js deleted file mode 100644 index fbfaba1..0000000 --- a/views/ABViewDataSelectCore.js +++ /dev/null @@ -1,47 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewDataSelectPropertyComponentDefaults = { - dataviewID: null, // uuid of ABDatacollection -}; - -const ABViewDefaults = { - key: "data-select", // {string} unique key for this view - icon: "chevron-circle-down", // {string} fa-[icon] reference for this view - labelKey: "Data Select", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDataSelectCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues ?? ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewDataSelectPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewDataviewCore.js b/views/ABViewDataviewCore.js deleted file mode 100644 index e2b0f63..0000000 --- a/views/ABViewDataviewCore.js +++ /dev/null @@ -1,84 +0,0 @@ -const ABViewDetail = require("../../platform/views/ABViewDetail"); - -const ABViewDataviewPropertyComponentDefaults = { - xCount: 1, // {int} the number of columns per row (need at least one) - detailsPage: "", - detailsTab: "", - editPage: "", - editTab: "", -}; - -const ABViewDataviewDefaults = { - key: "dataview", // {string} unique key for this view - icon: "th", // {string} fa-[icon] reference for this view - labelKey: "Data view", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDataviewCore extends ABViewDetail { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues || ABViewDataviewDefaults - ); - } - - static common() { - return ABViewDataviewDefaults; - } - - static defaultValues() { - return ABViewDataviewPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.xCount = parseInt( - this.settings.xCount || ABViewDataviewPropertyComponentDefaults.xCount - ); - this.settings.detailsPage = - this.settings.detailsPage || - ABViewDataviewPropertyComponentDefaults.detailsPage; - this.settings.editPage = - this.settings.editPage || - ABViewDataviewPropertyComponentDefaults.editPage; - this.settings.detailsTab = - this.settings.detailsTab || - ABViewDataviewPropertyComponentDefaults.detailsTab; - this.settings.editTab = - this.settings.editTab || - ABViewDataviewPropertyComponentDefaults.editTab; - } - - parentDetailComponent() { - let dataview = null; - - let curr = this; - while (curr.key != "dataview" && !curr.isRoot() && curr.parent) { - curr = curr.parent; - } - - if (curr.key == "dataview") { - dataview = curr; - } - - return dataview; - } -}; diff --git a/views/ABViewDetailCheckboxCore.js b/views/ABViewDetailCheckboxCore.js deleted file mode 100644 index 25e7c56..0000000 --- a/views/ABViewDetailCheckboxCore.js +++ /dev/null @@ -1,33 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailCheckboxPropertyComponentDefaults = {}; - -const ABViewDetailCheckboxDefaults = { - key: "detailcheckbox", // {string} unique key for this view - icon: "check-square-o", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.checkbox", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailCheckboxCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues ?? ABViewDetailCheckboxDefaults - ); - } - - static common() { - return ABViewDetailCheckboxDefaults; - } - - static defaultValues() { - return ABViewDetailCheckboxPropertyComponentDefaults; - } -}; diff --git a/views/ABViewDetailComponentCore.js b/views/ABViewDetailComponentCore.js deleted file mode 100644 index 6da844a..0000000 --- a/views/ABViewDetailComponentCore.js +++ /dev/null @@ -1,63 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -module.exports = class ABViewDetailComponentCore extends ABViewWidget { - // constructor(values, application, parent, defaultValues) { - // super(values, application, parent, defaultValues); - // } - - detailComponent() { - let detailView = null; - - let curr = this; - while ( - !curr.isRoot() && - curr.parent && - curr.key != "detail" && - curr.key != "dataview" - ) { - curr = curr.parent; - } - - if (curr.key == "detail" || curr.key == "dataview") { - detailView = curr; - } - - return detailView; - } - - field() { - let detailComponent = this.detailComponent(); - if (detailComponent == null) return null; - - let datacollection = detailComponent.datacollection; - if (datacollection == null) return null; - - let object = datacollection.datasource; - if (object == null) return null; - - let field = object.fields((v) => v.id == this.settings.fieldId)[0]; - - // set .alias to support queries that contains alias name - // [aliasName].[columnName] - if (field && this.settings.alias) { - field.alias = this.settings.alias; - } - - return field; - } - - getCurrentData() { - let detailCom = this.detailComponent(); - if (!detailCom) return null; - - let dv = detailCom.datacollection; - if (!dv) return null; - - let field = this.field(); - if (!field) return null; - - let currData = dv.getCursor(); - if (currData) return currData[field.columnName]; - else return null; - } -}; diff --git a/views/ABViewDetailConnectCore.js b/views/ABViewDetailConnectCore.js deleted file mode 100644 index 7683041..0000000 --- a/views/ABViewDetailConnectCore.js +++ /dev/null @@ -1,31 +0,0 @@ -// const ABViewDetailSelectivity = require("../../platform/views/ABViewDetailSelectivity"); -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailPropertyComponentDefaults = { - formView: "", // id of form to add new data -}; - -const ABViewDefaults = { - key: "detailconnect", // {string} unique key for this view - icon: "list-ul", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.connect", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailConnectCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues ?? ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewDetailPropertyComponentDefaults; - } -}; diff --git a/views/ABViewDetailCore.js b/views/ABViewDetailCore.js deleted file mode 100644 index 6d05e15..0000000 --- a/views/ABViewDetailCore.js +++ /dev/null @@ -1,104 +0,0 @@ -const ABViewContainer = require("../../platform/views/ABViewContainer"); - -const ABViewDetailDefaults = { - key: "detail", // {string} unique key for this view - icon: "file-text-o", // {string} fa-[icon] reference for this view - labelKey: "Detail", // {string} the multilingual label key for the class label -}; - -const ABViewDetailPropertyComponentDefaults = { - dataviewID: null, - showLabel: true, - labelPosition: "left", - labelWidth: 120, - height: 0, -}; - -module.exports = class ABViewDetailCore extends ABViewContainer { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues ?? ABViewDetailDefaults); - } - - static common() { - return ABViewDetailDefaults; - } - - static defaultValues() { - return ABViewDetailPropertyComponentDefaults; - } - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings.labelPosition = - this.settings.labelPosition || - ABViewDetailPropertyComponentDefaults.labelPosition; - - // convert from "0" => true/false - this.settings.showLabel = JSON.parse( - this.settings.showLabel != null - ? this.settings.showLabel - : ABViewDetailPropertyComponentDefaults.showLabel - ); - - // convert from "0" => 0 - this.settings.labelWidth = parseInt( - this.settings.labelWidth || - ABViewDetailPropertyComponentDefaults.labelWidth - ); - this.settings.height = parseInt( - this.settings.height ?? ABViewDetailPropertyComponentDefaults.height - ); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - let viewsToAllow = ["label", "text"], - allComponents = this.application.viewAll(); - - return allComponents.filter((c) => { - return viewsToAllow.indexOf(c.common().key) > -1; - }); - } - - addFieldToDetail(field, yPosition) { - if (field == null) return; - - let newView = field.detailComponent().newInstance(this.application, this); - if (newView == null) return; - - // set settings to component - newView.settings = newView.settings ?? {}; - newView.settings.fieldId = field.id; - newView.settings.labelWidth = - this.settings.labelWidth || - ABViewDetailPropertyComponentDefaults.labelWidth; - - // keep alias to support Query that contains alias name - // [alias].[columnName] - newView.settings.alias = field.alias; - - // TODO : Default settings - - newView.position.y = yPosition; - - // add a new component - this._views.push(newView); - - return newView; - } -}; diff --git a/views/ABViewDetailCustomCore.js b/views/ABViewDetailCustomCore.js deleted file mode 100644 index 01e75a2..0000000 --- a/views/ABViewDetailCustomCore.js +++ /dev/null @@ -1,33 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailCustomPropertyComponentDefaults = {}; - -const ABViewDetailCustomDefaults = { - key: "detailcustom", // {string} unique key for this view - icon: "dot-circle-o", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.custom", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailCustomCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues ?? ABViewDetailCustomDefaults - ); - } - - static common() { - return ABViewDetailCustomDefaults; - } - - static defaultValues() { - return ABViewDetailCustomPropertyComponentDefaults; - } -}; diff --git a/views/ABViewDetailImageCore.js b/views/ABViewDetailImageCore.js deleted file mode 100644 index bb0d6c5..0000000 --- a/views/ABViewDetailImageCore.js +++ /dev/null @@ -1,59 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailImagePropertyComponentDefaults = { - height: 80, - width: 120, -}; - -const ABViewDetailImageDefaults = { - key: "detailimage", // {string} unique key for this view - icon: "image", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.image", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailImageCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues ?? ABViewDetailImageDefaults - ); - } - - static common() { - return ABViewDetailImageDefaults; - } - - static defaultValues() { - return ABViewDetailImagePropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - this.settings.height = parseInt( - this.settings.height || - ABViewDetailImagePropertyComponentDefaults.height - ); - this.settings.width = parseInt( - this.settings.width ?? ABViewDetailImagePropertyComponentDefaults.width - ); - } -}; diff --git a/views/ABViewDetailItemCore.js b/views/ABViewDetailItemCore.js deleted file mode 100644 index c5d217f..0000000 --- a/views/ABViewDetailItemCore.js +++ /dev/null @@ -1,81 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -module.exports = class ABViewDetailItemCore extends ABViewWidget { - // constructor(values, application, parent, defaultValues) { - // super(values, application, parent, defaultValues); - // } - - detailComponent() { - let detailView = null; - - let curr = this; - while ( - !curr.isRoot() && - curr.parent && - curr.key != "detail" && - curr.key != "dataview" - ) { - curr = curr.parent; - } - - if (curr.key == "detail" || curr.key == "dataview") { - detailView = curr; - } - - return detailView; - } - - field() { - let detailComponent = this.detailComponent(); - if (detailComponent == null) return null; - - let datacollection = detailComponent.datacollection; - if (datacollection == null) return null; - - let object = datacollection.datasource; - if (object == null) return null; - - let field = object.fields((v) => v.id == this.settings.fieldId)[0]; - - // set .alias to support queries that contains alias name - // [aliasName].[columnName] - if (field && this.settings.alias) { - field.alias = this.settings.alias; - } - - return field; - } - - getCurrentData() { - let detailCom = this.detailComponent(); - if (!detailCom) return null; - - let dv = detailCom.datacollection; - if (!dv) return null; - - let field = this.field(); - if (!field) return null; - - let currData = dv.getCursor(); - if (currData) return currData[field.columnName]; - else return null; - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - /** - * @property datacollection - * return data source - * NOTE: this view doesn't track a DataCollection. - * @return {ABDataCollection} - */ - get datacollection() { - return null; - } -}; diff --git a/views/ABViewDetailSelectivityCore.js b/views/ABViewDetailSelectivityCore.js deleted file mode 100644 index d4a6ad0..0000000 --- a/views/ABViewDetailSelectivityCore.js +++ /dev/null @@ -1,49 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailPropertyComponentDefaults = { - height: 0, -}; - -const ABViewDefaults = { - key: "detailselectivity", // {string} unique key for this view - icon: "tasks", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.selectivity", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailSelectivityCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues ?? ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewDetailPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - this.settings.height = parseInt( - this.settings.height ?? ABViewDetailPropertyComponentDefaults.height - ); - } -}; diff --git a/views/ABViewDetailTextCore.js b/views/ABViewDetailTextCore.js deleted file mode 100644 index 2c763fc..0000000 --- a/views/ABViewDetailTextCore.js +++ /dev/null @@ -1,55 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailTextPropertyComponentDefaults = { - height: 0, -}; - -const ABViewDetailTextDefaults = { - key: "detailtext", // {string} unique key for this view - icon: "etsy", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.text", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailTextCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues ?? ABViewDetailTextDefaults - ); - } - - static common() { - return ABViewDetailTextDefaults; - } - - static defaultValues() { - return ABViewDetailTextPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - this.settings.height = parseInt( - this.settings.height || - ABViewDetailTextPropertyComponentDefaults.height - ); - } -}; diff --git a/views/ABViewDetailTreeCore.js b/views/ABViewDetailTreeCore.js deleted file mode 100644 index dc95ccb..0000000 --- a/views/ABViewDetailTreeCore.js +++ /dev/null @@ -1,33 +0,0 @@ -const ABViewDetailItem = require("../../platform/views/ABViewDetailItem"); - -const ABViewDetailPropertyComponentDefaults = {}; - -const ABViewDetailTreeDefaults = { - key: "detailtree", // {string} unique key for this view - icon: "sitemap", // {string} fa-[icon] reference for this view - labelKey: "ab.components.detail.tree", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewDetailTextCore extends ABViewDetailItem { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super( - values, - application, - parent, - defaultValues ?? ABViewDetailTreeDefaults - ); - } - - static common() { - return ABViewDetailTreeDefaults; - } - - static defaultValues() { - return ABViewDetailPropertyComponentDefaults; - } -}; diff --git a/views/ABViewGridCore.js b/views/ABViewGridCore.js deleted file mode 100644 index 2673f60..0000000 --- a/views/ABViewGridCore.js +++ /dev/null @@ -1,384 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewGridPropertyComponentDefaults = { - label: "", - // {string} - // label is required and you can add more if the component needs them - - // format:0 // 0 - normal, 1 - title, 2 - description - dataviewID: "", - // {uuid} - // uuid of ABDataCollection that drives the data for our Grid - - padding: 17, - // {int} - // the default padding surrounding the component - - showToolbar: 1, - // {bool} - // do we show our toolbar? - - isEditable: 0, - // {bool} - // do we allow editing in the grid? - - massUpdate: 0, - // {bool} - // do we allow the Mass Update capability? (row checkboxes and the - // MassUpdate popup) - - allowDelete: 0, - // {bool} - // do we allow deleting multiple rows at a time? Mass Delete. - - // isFilterable:0, - - isSortable: 1, - // {bool} - // do we allow the sort options. - - isExportable: 0, - // {bool} - // do we enable the webix export from grid capabilities? - - // linkedObject:'', - // linkedField:'', - // linkedPage:'', - // linkedPageView:'', - // linkedEditPage:'', - // linkedEditPageForm:'', - - detailsPage: "", - // {ABViewPage.id} - // the ABViewPage that has the details component. - - detailsTab: "", - // {ABViewTab.id} - // the ABViewTab component, that has the details component. - // NOTE: if your details is embedded on a TAB, we need both the - // .detailsPage & .detailsTab to successfully show the item. - - editPage: "", - // {ABViewPage.id} - // the ABViewPage that has the edit component. - - editTab: "", - // {ABViewTab.id} - // the ABViewTab component, that has the edit component. - // NOTE: if your editor is embedded on a TAB, we need both the - // .editPage & .editTab to successfully show the form. - - trackView: 0, - // {bool} - // Do we offer the ability to track changes to this object/row? - - frozenColumnID: "", - // {ABField.id} - // id of column you want to stop freezing the left hand side at. - - hiddenFields: [], - // {array} [ ABField.id, ABField.id, ... ] - // array of [ids] to add hidden:true to - - summaryColumns: [], - // {array} [ ABField.id, ABField.id, ... ] - // array of [ids] to add the SUM footer to - - countColumns: [], - // {array} [ ABField.id, ABField.id, ... ] - // array of [ids] to add the Count footer to - - // TODO: get rid of objectWorkspace! - objectWorkspace: { - // sortFields:[], // array of columns with their sort configurations - // filterConditions:[], // array of filters to apply to the data table - frozenColumnID: "", // id of column you want to stop freezing - hiddenFields: [], // array of [ids] to add hidden:true to - summaryColumns: [], - countColumns: [], - }, - gridFilter: { - filterOption: 1, - userFilterPosition: "toolbar", - isGlobalToolbar: 1, - }, - // summaryFields: [], // array of [field ids] to add the summary column in footer - // countFields: [], // array of [field ids] to add the summary column in footer - - height: 0, - // {int} - // The Height of our Grid. - // See ../views/ABViewDataview.js - - hideHeader: 0, - labelAsField: 0, - hideButtons: 0, - groupBy: "", // id of field - - // TODO: add to ABDesigner.interface design: - columnConfig: [], - // {array} [ {columnHeader}, {columnHeader} ... ] - // An array of column headers for the grid to display. These should - // be generated at Design time, and can allow the designer to ORDER the - // columns, assign column widths, fillspace, etc... - // {columnHeader} - // The minimum amount of information a Grid needs for it's customization - // .id {string} ABField.columnName - // .fieldId {string} ABField.id - // .width {int} - // .fillspace {bool} - // .minwidth - // - // When displaying column headers, we will ask the - // CurrentObject.columnHeaders(), and then modify them with our settings - // here. - - saveLocal: 1, - // {bool} - // Allow saving of local changes to our grid display. This will enable - // a user to modify the Grid display locally. -}; - -const ABViewDefaults = { - key: "grid", // {string} unique key for this view - icon: "table", // {string} fa-[icon] reference for this view - labelKey: "Grid", // {string} the multilingual label key for the class label -}; - -/** - * @function settingsDefault() - * Verifies a given field is set and if not, defaults to what we havein our - * ABViewGridPropertyComponentDefaults. - * NOTE: use this fn() for values that are NOT TRUTHY ... so not for numeric - * 1 or 0. - * @param {hash} base - * The current settings value hash. - * @param {string} field - * The parameter we are checking. - */ -function settingsDefault(base, field) { - if (typeof base[field] == "undefined") { - base[field] = ABViewGridPropertyComponentDefaults[field]; - return; - } - base[field] = base[field] || ABViewGridPropertyComponentDefaults[field]; -} - -/** - * @function settingsDefaultJSON() - * Verifies a given field is set and if not, defaults to what we havein our - * ABViewGridPropertyComponentDefaults. - * NOTE: use this fn() for values that ARE TRUTHY ... so for numeric 1 or 0 - * @param {hash} base - * The current settings value hash. - * @param {string} field - * The parameter we are checking. - */ -function settingsDefaultJSON(base, field) { - try { - if (typeof base[field] == "string") { - base[field] = JSON.parse(base[field]); - } - } catch (e) { - base[field] = ABViewGridPropertyComponentDefaults[field]; - } -} - -module.exports = class ABViewGridCore extends ABViewWidget { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABViewWidget} parent the ABViewWidget this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewGridPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // if this is being instantiated on a read from the Property UI, - settingsDefault(this.settings, "dataviewID"); - - // Convert to boolean - // these values are sometimes 0 (number) at this point so the JSON.parse - // with the || (or) statement was always falling to the default so I am - // trying to parse the value...if it fails we use the default value - settingsDefaultJSON(this.settings, "padding"); - settingsDefaultJSON(this.settings, "showToolbar"); - settingsDefaultJSON(this.settings, "isEditable"); - settingsDefaultJSON(this.settings, "massUpdate"); - settingsDefaultJSON(this.settings, "allowDelete"); - // this.settings.isFilterable = JSON.parse(this.settings.isFilterable || ABViewGridPropertyComponentDefaults.isFilterable); - settingsDefaultJSON(this.settings, "isSortable"); - settingsDefaultJSON(this.settings, "isExportable"); - settingsDefaultJSON(this.settings, "hideHeader"); - settingsDefaultJSON(this.settings, "labelAsField"); - settingsDefaultJSON(this.settings, "hideButtons"); - settingsDefaultJSON(this.settings, "columnConfig"); - settingsDefaultJSON(this.settings, "saveLocal"); - - this.settings.gridFilter = - this.settings.gridFilter || - ABViewGridPropertyComponentDefaults.gridFilter; - - try { - this.settings.gridFilter.filterOption = JSON.parse( - this.settings.gridFilter.filterOption - ); - } catch (e) { - this.settings.gridFilter.filterOption = - ABViewGridPropertyComponentDefaults.gridFilter.filterOption; - } - - try { - this.settings.gridFilter.isGlobalToolbar = JSON.parse( - this.settings.gridFilter.isGlobalToolbar - ); - } catch (e) { - this.settings.gridFilter.isGlobalToolbar = - ABViewGridPropertyComponentDefaults.gridFilter.isGlobalToolbar; - } - - // this.settings.linkedObject = this.settings.linkedObject || ABViewGridPropertyComponentDefaults.linkedObject; - // this.settings.linkedField = this.settings.linkedField || ABViewGridPropertyComponentDefaults.linkedField; - // this.settings.linkedPage = this.settings.linkedPage || ABViewGridPropertyComponentDefaults.linkedPage; - // this.settings.linkedPageView = this.settings.linkedPageView || ABViewGridPropertyComponentDefaults.linkedPageView; - // this.settings.linkedEditPage = this.settings.linkedEditPage || ABViewGridPropertyComponentDefaults.linkedEditPage; - // this.settings.linkedEditPageForm = this.settings.linkedEditPageForm || ABViewGridPropertyComponentDefaults.linkedEditPageForm; - - settingsDefault(this.settings, "detailsPage"); - settingsDefault(this.settings, "editPage"); - settingsDefault(this.settings, "detailsTab"); - settingsDefault(this.settings, "editTab"); - settingsDefaultJSON(this.settings, "trackView"); - - // TODO: remove objectworkspace! - // this.settings.objectWorkspace = - // this.settings.objectWorkspace || - // ABViewGridPropertyComponentDefaults.objectWorkspace; - - // if (typeof this.settings.objectWorkspace != "undefined") { - // if (typeof this.settings.objectWorkspace.sortFields == "undefined") - // this.settings.objectWorkspace.sortFields = []; - // if ( - // typeof this.settings.objectWorkspace.filterConditions == "undefined" - // ) - // this.settings.objectWorkspace.filterConditions = []; - // if (typeof this.settings.objectWorkspace.frozenColumnID == "undefined") - // this.settings.objectWorkspace.frozenColumnID = ""; - // if (typeof this.settings.objectWorkspace.hiddenFields == "undefined") - // this.settings.objectWorkspace.hiddenFields = []; - // if (typeof this.settings.objectWorkspace.summaryColumns == "undefined") - // this.settings.objectWorkspace.summaryColumns = []; - // if (typeof this.settings.objectWorkspace.countColumns == "undefined") - // this.settings.objectWorkspace.countColumns = []; - // } - - var owFields = [ - "sortFields", - "filterConditions", - "frozenColumnID", - "hiddenFields", - "summaryColumns", - "countColumns", - ]; - // Transition: if we have an .objectWorkspace, copy those values in here: - if (this.settings.objectWorkspace) { - owFields.forEach((f) => { - if (this.settings[f] == null) - this.settings[f] = this.settings.objectWorkspace[f]; - }); - } - - // make sure they have actual default values now. - owFields.forEach((f) => { - settingsDefault(this.settings, f); - }); - - // we are not allowed to have sub views: - this._views = []; - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - removeField(field, cb) { - let shouldSave = false; - - // check to see if there is a frozenColumnID and if it matches the - // deleted field - if (this.settings?.frozenColumnID == field.columnName) { - // remove the column name from the frozen column id - this.settings.frozenColumnID = ""; - // flag the object to be saved later - shouldSave = true; - } - - // check to see if there are hidden fields - if (this.settings.hiddenFields?.length) { - // find if the deleted field is in the array - let index = this.settings.hiddenFields.indexOf(field.columnName); - // if so splice it out of the array - if (index > -1) { - this.settings.hiddenFields.splice(index, 1); - // flag the object to be saved later - shouldSave = true; - } - } - - // check to see if there are Summary fields - if (this.settings.summaryColumns?.length) { - // find if the deleted field is in the array - let index = this.settings.summaryColumns.indexOf(field.id); - // if so splice it out of the array - if (index > -1) { - this.settings.summaryColumns.splice(index, 1); - // flag the object to be saved later - shouldSave = true; - } - } - - // check to see if there are hidden fields - if (this.settings.countColumns?.length) { - // find if the deleted field is in the array - let index = this.settings.countColumns.indexOf(field.id); - // if so splice it out of the array - if (index > -1) { - this.settings.countColumns.splice(index, 1); - // flag the object to be saved later - shouldSave = true; - } - } - // if settings were changed call the callback - - cb(null, shouldSave); - } - - copyUpdateProperyList() { - return ["detailsPage", "detailsTab", "editPage", "editTab"]; - } -}; diff --git a/views/ABViewImageCore.js b/views/ABViewImageCore.js deleted file mode 100644 index 82668b3..0000000 --- a/views/ABViewImageCore.js +++ /dev/null @@ -1,67 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewImagePropertyComponentDefaults = { - filename: "", - width: 200, - height: 100, -}; - -const ABViewDefaults = { - key: "image", // {string} unique key for this view - icon: "picture-o", // {string} fa-[icon] reference for this view - labelKey: "Image", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewImageCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewImagePropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - /** - * @property datacollection - * return data source - * NOTE: this view doesn't track a DataCollection. - * @return {ABDataCollection} - */ - get datacollection() { - return null; - } - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - this.settings.width = parseInt( - this.settings.width || ABViewImagePropertyComponentDefaults.width - ); - this.settings.height = parseInt( - this.settings.height || ABViewImagePropertyComponentDefaults.height - ); - } -}; diff --git a/views/ABViewKanbanCore.js b/views/ABViewKanbanCore.js deleted file mode 100644 index 81b766c..0000000 --- a/views/ABViewKanbanCore.js +++ /dev/null @@ -1,88 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewKanbanPropertyComponentDefaults = { - dataviewID: null, - // {uuid} - // The ABDataCollection.uuid that we are using to store the data. - // NOTE: we actually use the DC to get the ABObject it is connected to. - - editFields: [], - // {array} - // An array of {ABField.id} that determines which fields should show up - // in the editor. - - verticalGroupingField: "", - // {ABField.id} - // the .id of the ABField instance that determines the Vertical Grouping - // of the Kanban. - - horizontalGroupingField: "", - // {ABField.id} - // the .id of the ABField instance that determines the horizontal Grouping - // of the Kanban. - - ownerField: "", - // {ABFieldUser.id} - // the .id of the ABFieldUser instance that determines the owner of the - // entries. - - template: "", - // {json} - // The {ABViewText} definition used to display the template for this KanBan. - // - // A display template used for displaying the information in each Card. The - // template is a basic string with special placeholders: {field.id} - // Given a row of data, the current object will scan the template for any - // placeholders matching one of it's fields, and then update it with the - // current value. -}; - -const ABViewDefaults = { - key: "kanban", - // {string} - // unique key identifier for this ABView object - - icon: "columns", - // {string} - // font-awesome icon reference: (without 'fa-' ) - - labelKey: "Kanban", - // {string} - // the multilingual label key - // NOTE: will be used as L(labelKey) -}; - -module.exports = class ABViewKanbanCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - fromValues(values) { - super.fromValues(values); - - // set a default .template value - if (!this.settings.template) { - this.settings.template = { id: `${this.id}_template`, key: "text" }; - this.settings.template.text = this.settings.textTemplate; - } - - this.TextTemplate = this.AB.viewNewDetatched(this.settings.template); - } - - toObj() { - var obj = super.toObj(); - obj.settings.template = this.TextTemplate.toObj(); - // NOTE: this corrects the initial save where this.id == undefined - // all the rest will set the .id correctly. - obj.settings.template.id = `${this.id}_template`; - return obj; - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewKanbanPropertyComponentDefaults; - } -}; diff --git a/views/ABViewLayoutCore.js b/views/ABViewLayoutCore.js deleted file mode 100644 index b68848e..0000000 --- a/views/ABViewLayoutCore.js +++ /dev/null @@ -1,81 +0,0 @@ -const ABViewContainer = require("../../platform/views/ABViewContainer"); -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const PropertyComponentDefaults = { - label: "", - numColumns: 1, // The number of columns for this layout -}; - -const ABViewDefaults = { - key: "layout", // {string} unique key for this view - icon: "columns", // {string} fa-[icon] reference for this view - labelKey: "Layout", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewLayoutCore extends ABViewWidget { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABView} parent the ABView this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return PropertyComponentDefaults; - } - - /** - * @method addColumn - * method to actually add a new ABView as one of our columns. - * This is called by the static .addView() method. - */ - addColumn() { - this._views.push( - this.application.viewNew( - { - key: ABViewContainer.common().key, - }, - this - ) - ); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - * @param {bool} isEdited is this component currently in the Interface Editor - * @return {array} of ABView objects. - */ - componentList(isEdited) { - if (isEdited) { - // if the layout component is being edited in the editor (isEdited == true) - // then we return []; - return []; - } else { - // the layout view doesn't care what components are offered, it get's - // the list from it's parent view. - // ## NOTE: layout views should not be root views. - if (this.parent) { - return this.parent.componentList(false); - } else { - return []; - } - } - } - - /** - * @property datacollection - * return data source - * NOTE: this view doesn't track a DataCollection. - * @return {ABDataCollection} - */ - get datacollection() { - return null; - } -}; diff --git a/views/ABViewListCore.js b/views/ABViewListCore.js deleted file mode 100644 index 17470ad..0000000 --- a/views/ABViewListCore.js +++ /dev/null @@ -1,45 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewListPropertyComponentDefaults = { - dataviewID: null, - field: null, - height: 0, -}; - -const ABViewDefaults = { - key: "list", // {string} unique key for this view - icon: "list-ul", // {string} fa-[icon] reference for this view - labelKey: "List", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewLabelCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewListPropertyComponentDefaults; - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - field() { - var dv = this.datacollection; - if (!dv) return null; - - var object = dv.datasource; - if (!object) return null; - - return object.fieldByID(this.settings.field); - } -}; diff --git a/views/ABViewTabCore.js b/views/ABViewTabCore.js deleted file mode 100644 index 5737821..0000000 --- a/views/ABViewTabCore.js +++ /dev/null @@ -1,82 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); -const ABViewContainer = require("../../platform/views/ABViewContainer"); - -const ABViewTabPropertyComponentDefaults = { - height: 0, - minWidth: 0, - stackTabs: 0, // use sidebar view instead of tabview - darkTheme: 0, // set dark theme css or not - sidebarWidth: 200, // width of sidebar menu when stacking tabs - sidebarPos: "left", // the default position of sidebar - iconOnTop: 0, // do you want to put the icon above the text label? - hintID: null, // store the ID of a webix hint tutorial for this view -}; - -const ABViewTabDefaults = { - key: "tab", // {string} unique key for this view - icon: "window-maximize", // {string} fa-[icon] reference for this view - labelKey: "Tab", // {string} the multilingual label key for the class label -}; - -module.exports = class ABViewTabCore extends ABViewWidget { - /** - * @param {obj} values key=>value hash of ABView values - * @param {ABApplication} application the application object this view is under - * @param {ABViewWidget} parent the ABViewWidget this view is a child of. (can be null) - */ - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewTabDefaults); - } - - static common() { - return ABViewTabDefaults; - } - - static defaultValues() { - return ABViewTabPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - // convert from "0" => 0 - this.settings.height = parseInt(this.settings.height); - this.settings.minWidth = parseInt(this.settings.minWidth || 0); - this.settings.stackTabs = parseInt(this.settings.stackTabs); - this.settings.darkTheme = parseInt(this.settings.darkTheme); - this.settings.sidebarWidth = parseInt(this.settings.sidebarWidth); - // this.settings.sidebarPos = this.settings.sidebarPos; - this.settings.iconOnTop = parseInt(this.settings.iconOnTop); - } - - addTab(tabName, tabIcon) { - return this.application - .viewNew( - { - key: ABViewContainer.common().key, - label: tabName, - tabicon: tabIcon, - }, - this - ) - .save(); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } -}; diff --git a/views/ABViewTextCore.js b/views/ABViewTextCore.js deleted file mode 100644 index 0af4032..0000000 --- a/views/ABViewTextCore.js +++ /dev/null @@ -1,214 +0,0 @@ -const ABViewWidget = require("../../platform/views/ABViewWidget"); - -const ABViewTextPropertyComponentDefaults = { - text: "", - // {string} - // A multilingual text template that is used to display a given set of - // values. - - height: 0, - // {integer} - // The default height of this widget. - - dataviewID: null, - // {uuid} - // The {ABDataCollection.id} of the datacollection this ABViewText is - // pulling data from. - // In most usage situations this ABView is tied to the data in an - // ABDataCollection. However, it is possible for an ABObject to be - // directly assigned to the ABView, and that will be used instead. -}; - -const ABViewDefaults = { - key: "text", - // {string} - // unique key for this view - - icon: "font", - // {string} - // fa-[icon] reference for this view - - labelKey: "Text", - // {string} - // the multilingual label key for the class label -}; - -module.exports = class ABViewTextCore extends ABViewWidget { - constructor(values, application, parent, defaultValues) { - super(values, application, parent, defaultValues || ABViewDefaults); - - this._object = null; - } - - static common() { - return ABViewDefaults; - } - - static defaultValues() { - return ABViewTextPropertyComponentDefaults; - } - - /// - /// Instance Methods - /// - - /** - * @method toObj() - * - * properly compile the current state of this ABViewLabel instance - * into the values needed for saving. - * - * @return {json} - */ - toObj() { - // NOTE: ABView auto translates/untranslates "label" - // add in any additional fields here: - this.unTranslate(this, this, ["text"]); - - var obj = super.toObj(); - obj.views = []; - return obj; - } - - /** - * @method fromValues() - * - * initialze this object with the given set of values. - * @param {obj} values - */ - fromValues(values) { - super.fromValues(values); - - this.settings = this.settings || {}; - - // convert from "0" => 0 - this.settings.height = parseInt( - this.settings.height || ABViewTextPropertyComponentDefaults.height - ); - - // if this is being instantiated on a read from the Property UI, - this.text = values.text || ABViewTextPropertyComponentDefaults.text; - - // NOTE: ABView auto translates/untranslates "label" - // add in any additional fields here: - this.translate(this, this, ["text"]); - } - - /** - * @method componentList - * return the list of components available on this view to display in the editor. - */ - componentList() { - return []; - } - - /** - * @property datacollection - * return ABDatacollection of this form - * - * @return {ABDatacollection} - */ - get datacollection() { - if (this.parent?.key == "dataview") { - return this.AB.datacollectionByID(this.parent.settings.dataviewID); - } else { - return this.AB.datacollectionByID(this.settings.dataviewID); - } - } - - fieldKey(field) { - let label = field.label || ""; - label = label.replace(/\(/g, "\\("); - label = label.replace(/\)/g, "\\)"); - return label; - } - - displayText(val, componentID) { - var result = this.text; - - let clearTemplateValue = (result) => { - return result.replace(/{(.*?)}/g, ""); - }; - - var dv = this.datacollection; - // if (!dv) return clearTemplateValue(result); - - var object = dv?.datasource ?? this._object; - if (!object) return clearTemplateValue(result); - - const rowData = val || dv.getCursor() || {}; - - object.fields().forEach((f) => { - // add \\ in front of the regular expression special charactors - // let label = f.label || ""; - // label = label.replace(/\(/g, "\\("); - // label = label.replace(/\)/g, "\\)"); - let label = this.fieldKey(f); - - var template = new RegExp("{" + label + "}", "g"); - - // IDEA: I'd like to keep all the image url logic INSIDE the ABFieldImage - // object. Is there some way we can simply call: f.imageTemplate(rowData) - // and parse the results for the url to display here? - - var data = f.format(rowData); - if (f.key == "image") { - var fData = data; - data = f.urlImage(fData); - - // Question: should we change f.urlImage() to return the defaultImageUrl - // if fData is "" and .useDefaultImage = true? - - if ( - !fData && - f.settings.defaultImageUrl && - f.settings.useDefaultImage - ) { - data = f.urlImage(f.settings.defaultImageUrl); - - //// - //// James: Revisit this and make sure we are handling things ok now. - // result = result.replace( - // "img", - // 'img onload=\'AD.comm.hub.publish("component.adjust", {"containerID": "' + - // componentID + - // "\"});' " - // ); - // } else if ( - // fData != "" && - // result.indexOf("onload") == -1 && - // componentID - // ) { - // result = result.replace( - // "img", - // 'img onload=\'AD.comm.hub.publish("component.adjust", {"containerID": "' + - // componentID + - // "\"});' " - // ); - } else { - //// - //// James: It looks like this routine assumes the this.text template will - //// only have 1 tag in it. Is that necessarilly true? - //// - //// If NOT, then we need to rethink this next line: - - result = result.replace( - "img", - "img onerror='this.parentNode.removeChild(this);' " - ); - } - } - - result = result.replace(template, data); - }); - - // Support {uuid} tag in tempalte - result = result.replace(/{PK}/g, rowData[object.PK()]); - - return result; - } - - objectLoad(object) { - this._object = object; - } -};