Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AppBuilder/core
Submodule core updated from 6120ef to 8677dd
6 changes: 4 additions & 2 deletions AppBuilder/platform/plugins/included/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import viewCsvImporter from "./view_csvImporter/FNAbviewcsvimporter.js";
import viewList from "./view_list/FNAbviewlist.js";
import viewTab from "./view_tab/FNAbviewtab.js";
import viewCSV from "./view_csvExporter/FNAbviewcsvexporter.js";
import viewLabel from "./view_label/FNAbviewlabel.js";

import viewText from "./view_text/FNAbviewtext.js";
import viewImage from "./view_image/FNAbviewimage.js";
import viewDataSelect from "./view_data-select/FNAbviewdataselect.js";
import viewPdfImporter from "./view_pdfImporter/FNAbviewpdfimporter.js";

const AllPlugins = [
viewCSV,
viewTab,
viewList,
viewText,
viewLabel,
viewImage,
viewDataSelect,
viewPdfImporter,
];
, viewCsvImporter];

export default {
load: (AB) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import FNAbviewcsvexporterComponent from "./FNAbviewcsvexporterComponent.js";


// FNAbviewcsvexporter Web
// A web side import for an ABView.
//
export default function FNAbviewcsvexporter({
/*AB,*/
ABViewWidgetPlugin,
ABViewComponentPlugin,
ABViewContainer
}) {
const ABAbviewcsvexporterComponent = FNAbviewcsvexporterComponent({ ABViewComponentPlugin });

const ABViewCSVExporterDefaults = {
key: "csvExporter", // unique key identifier for this ABViewForm
icon: "download", // icon reference: (without 'fa-' )
labelKey: "CSV Exporter", // {string} the multilingual label key for the class label
};

const ABViewCSVExporterPropertyComponentDefaults = {
dataviewID: null,
where: null,
buttonLabel: "Export CSV",
filename: "exportCSV",
hasHeader: true,
width: 150,
hiddenFieldIds: [],
};

class ABViewCSVExporterCore extends ABViewWidgetPlugin {
constructor(values, application, parent, defaultValues) {
super(
values,
application,
parent,
defaultValues || ABViewCSVExporterDefaults
);
}

static common() {
return ABViewCSVExporterDefaults;
}

static defaultValues() {
return ABViewCSVExporterPropertyComponentDefaults;
}

///
/// Instance Methods
///

/**
* @method fromValues()
*
* initialze this object with the given set of values.
* @param {obj} values
*/
fromValues(values) {
super.fromValues(values);

// convert to boolean
if (typeof values.settings.hasHeader == "string")
this.settings.hasHeader = JSON.parse(values.settings.hasHeader);

if (this.settings.hasHeader == null)
this.settings.hasHeader =
ABViewCSVExporterPropertyComponentDefaults.hasHeader;

// convert from "0" => 0
this.settings.width = parseInt(
values.settings.width ||
ABViewCSVExporterPropertyComponentDefaults.width
);

this.settings.hiddenFieldIds =
values.settings.hiddenFieldIds ||
ABViewCSVExporterPropertyComponentDefaults.hiddenFieldIds;
}
};

return class ABViewCSVExporter extends ABViewCSVExporterCore {

/**
* @method getPluginKey
* return the plugin key for this view.
* @return {string} plugin key
*/
static getPluginKey() {
return this.common().key;
}

/**
* @method component()
* return a UI component based upon this view.
* @return {obj} UI component
*/
component(parentId) {
return new ABAbviewcsvexporterComponent(this, parentId);
}




warningsEval() {
super.warningsEval();

let DC = this.datacollection;
if (!DC) {
this.warningsMessage(
`can't resolve it's datacollection[${this.settings.dataviewID}]`
);
}
}
};

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const ABViewComponent = require("./ABViewComponent").default;
export default function FNAbviewcsvexporterComponent({
/*AB,*/
ABViewComponentPlugin,
}) {
return class ABAbviewcsvexporterComponent extends ABViewComponentPlugin {


module.exports = class ABViewCSVExporterComponent extends ABViewComponent {
constructor(baseView, idBase, ids) {
super(
baseView,
Expand Down Expand Up @@ -131,4 +135,8 @@ module.exports = class ABViewCSVExporterComponent extends ABViewComponent {
$buttonFilter.define("badge", (where.rules || []).length || null);
$buttonFilter.refresh();
}
};


};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import FNAbviewcsvimporterComponent from "./FNAbviewcsvimporterComponent.js";


// FNAbviewcsvimporter Web
// A web side import for an ABView.
//
export default function FNAbviewcsvimporter({
/*AB,*/
ABViewWidgetPlugin,
ABViewComponentPlugin,
ABViewContainer
}) {
const ABAbviewcsvimporterComponent = FNAbviewcsvimporterComponent({ ABViewComponentPlugin });

const ABRecordRule = require("../../../../rules/ABViewRuleListFormRecordRules");

const ABViewCSVImporterDefaults = {
key: "csvImporter",
// {string}
// unique key identifier for this ABViewForm

icon: "upload",
// {string}
// font-awesome icon reference: (without 'fa-' )

labelKey: "CSV Importer",
// {string}
// the multilingual label key for the class label
// NOTE: will be used as L(labelKey)
};

const ABViewCSVImporterPropertyComponentDefaults = {
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.

availableFieldIds: [],
//{array}
// A list of ABField.ids that are allowed to be imported using this widget.

buttonLabel: "Upload CSV",
// {string}
// The Label(key) to display on the initial button

width: 0,
// {integer}
// Width of the Popup.

recordRules: [],
// {array} [ {RecordRule}, ... ]
// A list of ABViewRuleListFormRecordRules that should be performed upon
// each row of data imported.
// The Array should look like:
// [{
// action: {string},
// when: [
// {
// fieldId: {UUID},
// comparer: {string},
// value: {string}
// }
// ],
// values: [
// {
// fieldId: {UUID},
// value: {object}
// }
// ]
// }]
};

class ABViewCSVImporterCore extends ABViewWidgetPlugin {
constructor(values, application, parent, defaultValues) {
super(
values,
application,
parent,
defaultValues || ABViewCSVImporterDefaults
);
}

/**
* @method common()
* Provides the default settings for an instance of an ABViewCSVImporter
* @return {json}
*/
static common() {
return ABViewCSVImporterDefaults;
}

/**
* @method defaultValues()
* Provides the default settings for an instance of an ABViewCSVImporter
* Component that is displayed on the UI.
* @return {json}
*/
static defaultValues() {
return ABViewCSVImporterPropertyComponentDefaults;
}

///
/// 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.width = parseInt(
this.settings.width || ABViewCSVImporterPropertyComponentDefaults.width
);
}

get RecordRule() {
let object = this.datacollection?.datasource;
if (!object) return null;

if (this._recordRule == null) {
this._recordRule = new ABRecordRule();
}

this._recordRule.formLoad(this);
this._recordRule.fromSettings(this.settings.recordRules);
this._recordRule.objectLoad(object);

return this._recordRule;
}

doRecordRulesPre(rowDatas) {
if (rowDatas && !Array.isArray(rowDatas)) {
rowDatas = [rowDatas];
}

rowDatas.forEach((row) => {
this.RecordRule?.processPre({ data: row.data || row, form: this });
});
}

doRecordRules(rowDatas) {
if (rowDatas && !Array.isArray(rowDatas)) {
rowDatas = [rowDatas];
}

if (!this.RecordRule) return Promise.resolve();

let tasks = [];

rowDatas.forEach((row) => {
tasks.push(
this.RecordRule.process({ data: row.data || row, form: this })
);
});

return Promise.all(tasks);
}
};

return class ABViewCSVImporter extends ABViewCSVImporterCore {

/**
* @method getPluginKey
* return the plugin key for this view.
* @return {string} plugin key
*/
static getPluginKey() {
return this.common().key;
}

/**
* @method component()
* return a UI component based upon this view.
* @return {obj} UI component
*/
component(parentId) {
return new ABAbviewcsvimporterComponent(this, parentId);
}




warningsEval() {
super.warningsEval();

let DC = this.datacollection;
if (!DC) {
this.warningsMessage(
`can't resolve it's datacollection[${this.settings.dataviewID}]`
);
}

if (!this.settings.availableFieldIds?.length) {
this.warningsMessage("has no fields set for matching import data");
}
}
};

}

Loading