mirror of
https://github.com/frappe/books.git
synced 2024-11-08 23:00:56 +00:00
create electron folder
This commit is contained in:
parent
edb0924375
commit
f5a1af401f
4
dist/css/style.css
vendored
4
dist/css/style.css
vendored
@ -7380,8 +7380,6 @@ html {
|
||||
padding-bottom: 0; }
|
||||
.page .page-links {
|
||||
padding: 1rem 2rem; }
|
||||
.page .page-links .page-link {
|
||||
display: inline-block; }
|
||||
.page .page-error {
|
||||
text-align: center;
|
||||
padding: 200px 0px; }
|
||||
@ -7436,6 +7434,8 @@ html {
|
||||
.table-page-wrapper {
|
||||
width: 100%;
|
||||
padding: 1rem 2rem; }
|
||||
.filter-toolbar {
|
||||
padding: 1rem 2rem; }
|
||||
.table-wrapper {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem; }
|
||||
|
287
dist/js/bundle.js
vendored
287
dist/js/bundle.js
vendored
@ -9866,6 +9866,10 @@ var meta = class BaseMeta extends document$1 {
|
||||
return this._field_map[fieldname];
|
||||
}
|
||||
|
||||
getLabel(fieldname) {
|
||||
return this.getField(fieldname).label;
|
||||
}
|
||||
|
||||
getTableFields() {
|
||||
if (this._tableFields===undefined) {
|
||||
this._tableFields = this.fields.filter(field => field.fieldtype === 'Table');
|
||||
@ -27171,7 +27175,7 @@ var page = class Page extends observable {
|
||||
this.wrapper = frappejs.ui.add('div', 'page hide', this.parent);
|
||||
this.head = frappejs.ui.add('div', 'page-nav clearfix hide', this.wrapper);
|
||||
this.titleElement = frappejs.ui.add('h3', 'page-title', this.wrapper);
|
||||
this.linksElement = frappejs.ui.add('div', 'page-links hide', this.wrapper);
|
||||
this.linksElement = frappejs.ui.add('div', 'btn-group page-links hide', this.wrapper);
|
||||
this.body = frappejs.ui.add('div', 'page-body', this.wrapper);
|
||||
}
|
||||
|
||||
@ -27188,7 +27192,7 @@ var page = class Page extends observable {
|
||||
}
|
||||
|
||||
addLink(label, action, unhide = true) {
|
||||
const link = frappejs.ui.add('a', 'page-link', this.linksElement, label);
|
||||
const link = frappejs.ui.add('button', 'btn btn-sm btn-outline-secondary', this.linksElement, label);
|
||||
link.addEventListener('click', action);
|
||||
if (unhide) {
|
||||
this.linksElement.classList.remove('hide');
|
||||
@ -44607,6 +44611,27 @@ $.scrollTop = function scrollTop(element, pixels) {
|
||||
});
|
||||
};
|
||||
|
||||
$.scrollbarWidth = function scrollbarWidth() {
|
||||
// Create the measurement node
|
||||
const scrollDiv = document.createElement('div');
|
||||
$.style(scrollDiv, {
|
||||
width: '100px',
|
||||
height: '100px',
|
||||
overflow: 'scroll',
|
||||
position: 'absolute',
|
||||
top: '-9999px'
|
||||
});
|
||||
document.body.appendChild(scrollDiv);
|
||||
|
||||
// Get the scrollbar width
|
||||
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
|
||||
// Delete the DIV
|
||||
document.body.removeChild(scrollDiv);
|
||||
|
||||
return scrollbarWidth;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is the
|
||||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
||||
@ -44641,12 +44666,10 @@ var isObject_1 = isObject;
|
||||
|
||||
var commonjsGlobal$$1 = typeof window !== 'undefined' ? window : typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof self !== 'undefined' ? self : {};
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = typeof commonjsGlobal$$1 == 'object' && commonjsGlobal$$1 && commonjsGlobal$$1.Object === Object && commonjsGlobal$$1;
|
||||
|
||||
var _freeGlobal = freeGlobal;
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
@ -44654,34 +44677,16 @@ var root = _freeGlobal || freeSelf || Function('return this')();
|
||||
|
||||
var _root = root;
|
||||
|
||||
/**
|
||||
* Gets the timestamp of the number of milliseconds that have elapsed since
|
||||
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 2.4.0
|
||||
* @category Date
|
||||
* @returns {number} Returns the timestamp.
|
||||
* @example
|
||||
*
|
||||
* _.defer(function(stamp) {
|
||||
* console.log(_.now() - stamp);
|
||||
* }, _.now());
|
||||
* // => Logs the number of milliseconds it took for the deferred invocation.
|
||||
*/
|
||||
var now = function() {
|
||||
return _root.Date.now();
|
||||
};
|
||||
|
||||
var now_1 = now;
|
||||
|
||||
/** Built-in value references. */
|
||||
var Symbol = _root.Symbol;
|
||||
|
||||
var _Symbol = Symbol;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
@ -44749,9 +44754,8 @@ function objectToString(value) {
|
||||
|
||||
var _objectToString = objectToString;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var nullTag = '[object Null]',
|
||||
undefinedTag = '[object Undefined]';
|
||||
var nullTag = '[object Null]';
|
||||
var undefinedTag = '[object Undefined]';
|
||||
|
||||
/** Built-in value references. */
|
||||
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
||||
@ -44804,7 +44808,6 @@ function isObjectLike(value) {
|
||||
|
||||
var isObjectLike_1 = isObjectLike;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var symbolTag = '[object Symbol]';
|
||||
|
||||
/**
|
||||
@ -44831,7 +44834,6 @@ function isSymbol(value) {
|
||||
|
||||
var isSymbol_1 = isSymbol;
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var NAN = 0 / 0;
|
||||
|
||||
/** Used to match leading and trailing whitespace. */
|
||||
@ -44895,12 +44897,11 @@ function toNumber(value) {
|
||||
|
||||
var toNumber_1 = toNumber;
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max,
|
||||
nativeMin = Math.min;
|
||||
var nativeMax = Math.max;
|
||||
var nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* Creates a debounced function that delays invoking `func` until after `wait`
|
||||
@ -45082,7 +45083,6 @@ function debounce(func, wait, options) {
|
||||
|
||||
var debounce_1 = debounce;
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT$1 = 'Expected a function';
|
||||
|
||||
/**
|
||||
@ -45168,10 +45168,6 @@ function makeDataAttributeString(props) {
|
||||
.trim();
|
||||
}
|
||||
|
||||
function getDefault(a, b) {
|
||||
return a !== undefined ? a : b;
|
||||
}
|
||||
|
||||
function copyTextToClipboard(text) {
|
||||
// https://stackoverflow.com/a/30810322/5353542
|
||||
var textArea = document.createElement('textarea');
|
||||
@ -45233,18 +45229,27 @@ function isNumeric(val) {
|
||||
|
||||
let throttle$1 = throttle_1;
|
||||
|
||||
let debounce$1 = debounce_1;
|
||||
let debounce$2 = debounce_1;
|
||||
|
||||
function promisify(fn, context = null) {
|
||||
function nextTick(fn, context = null) {
|
||||
return (...args) => {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
const execute = () => {
|
||||
const out = fn.apply(context, args);
|
||||
resolve(out);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
if (window.setImmediate) {
|
||||
setImmediate(execute);
|
||||
} else if (window.requestAnimationFrame) {
|
||||
requestAnimationFrame(execute);
|
||||
} else {
|
||||
setTimeout(execute);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function linkProperties(target, source, properties) {
|
||||
const props = properties.reduce((acc, prop) => {
|
||||
acc[prop] = {
|
||||
@ -45256,6 +45261,7 @@ function linkProperties(target, source, properties) {
|
||||
}, {});
|
||||
Object.defineProperties(target, props);
|
||||
}
|
||||
|
||||
function isSet(val) {
|
||||
return val !== undefined || val !== null;
|
||||
}
|
||||
@ -45278,10 +45284,10 @@ function ensureArray(val) {
|
||||
class DataManager {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.sortRows = promisify(this.sortRows, this);
|
||||
this.switchColumn = promisify(this.switchColumn, this);
|
||||
this.removeColumn = promisify(this.removeColumn, this);
|
||||
this.filterRows = promisify(this.filterRows, this);
|
||||
this.sortRows = nextTick(this.sortRows, this);
|
||||
this.switchColumn = nextTick(this.switchColumn, this);
|
||||
this.removeColumn = nextTick(this.removeColumn, this);
|
||||
this.filterRows = nextTick(this.filterRows, this);
|
||||
}
|
||||
|
||||
init(data, columns) {
|
||||
@ -45323,7 +45329,7 @@ class DataManager {
|
||||
}
|
||||
|
||||
prepareDefaultColumns() {
|
||||
if (this.options.addCheckboxColumn && !this.hasColumnById('_checkbox')) {
|
||||
if (this.options.checkboxColumn && !this.hasColumnById('_checkbox')) {
|
||||
const cell = {
|
||||
id: '_checkbox',
|
||||
content: this.getCheckboxHTML(),
|
||||
@ -45337,7 +45343,7 @@ class DataManager {
|
||||
this.columns.push(cell);
|
||||
}
|
||||
|
||||
if (this.options.addSerialNoColumn && !this.hasColumnById('_rowIndex')) {
|
||||
if (this.options.serialNoColumn && !this.hasColumnById('_rowIndex')) {
|
||||
let cell = {
|
||||
id: '_rowIndex',
|
||||
content: '',
|
||||
@ -45374,6 +45380,7 @@ class DataManager {
|
||||
.map((cell, i) => this.prepareCell(cell, i))
|
||||
.map(col => Object.assign({}, baseCell, col))
|
||||
.map(col => {
|
||||
col.content = col.content || col.name || '';
|
||||
col.id = col.id || col.content;
|
||||
return col;
|
||||
});
|
||||
@ -45425,10 +45432,10 @@ class DataManager {
|
||||
|
||||
if (Array.isArray(d)) {
|
||||
// row is an array
|
||||
if (this.options.addCheckboxColumn) {
|
||||
if (this.options.checkboxColumn) {
|
||||
row.push(this.getCheckboxHTML());
|
||||
}
|
||||
if (this.options.addSerialNoColumn) {
|
||||
if (this.options.serialNoColumn) {
|
||||
row.push((index + 1) + '');
|
||||
}
|
||||
row = row.concat(d);
|
||||
@ -45752,11 +45759,11 @@ class DataManager {
|
||||
}
|
||||
|
||||
getStandardColumnCount() {
|
||||
if (this.options.addCheckboxColumn && this.options.addSerialNoColumn) {
|
||||
if (this.options.checkboxColumn && this.options.serialNoColumn) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (this.options.addCheckboxColumn || this.options.addSerialNoColumn) {
|
||||
if (this.options.checkboxColumn || this.options.serialNoColumn) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -45775,6 +45782,12 @@ class DataManager {
|
||||
|
||||
getColumn(colIndex) {
|
||||
colIndex = +colIndex;
|
||||
|
||||
if (colIndex < 0) {
|
||||
// negative indexes
|
||||
colIndex = this.columns.length + colIndex;
|
||||
}
|
||||
|
||||
return this.columns.find(col => col.colIndex === colIndex);
|
||||
}
|
||||
|
||||
@ -45945,7 +45958,7 @@ class ColumnManager {
|
||||
let html = this.rowmanager.getRowHTML(columns, {
|
||||
isHeader: 1
|
||||
});
|
||||
if (this.options.enableInlineFilters) {
|
||||
if (this.options.inlineFilters) {
|
||||
html += this.rowmanager.getRowHTML(columns, {
|
||||
isFilter: 1
|
||||
});
|
||||
@ -46095,9 +46108,8 @@ class ColumnManager {
|
||||
const $cell = span.closest('.data-table-cell');
|
||||
let {
|
||||
colIndex,
|
||||
sortOrder
|
||||
sortOrder = 'none'
|
||||
} = $.data($cell);
|
||||
sortOrder = getDefault(sortOrder, 'none');
|
||||
const col = this.getColumn(colIndex);
|
||||
|
||||
if (col && col.sortable === false) {
|
||||
@ -46179,6 +46191,14 @@ class ColumnManager {
|
||||
});
|
||||
}
|
||||
|
||||
freezeColumn(colIndex) {
|
||||
const columns = this.datamanager.getColumns().slice(0, colIndex + 1);
|
||||
console.log(columns);
|
||||
this.fixedColumns = new DataTable(this.instance.fixedColumnsWrapper, Object.assign({}, this.options, {
|
||||
columns
|
||||
}));
|
||||
}
|
||||
|
||||
toggleFilter(flag) {
|
||||
let showFilter;
|
||||
if (flag === undefined) {
|
||||
@ -46205,7 +46225,7 @@ class ColumnManager {
|
||||
}
|
||||
|
||||
bindFilter() {
|
||||
if (!this.options.enableInlineFilters) return;
|
||||
if (!this.options.inlineFilters) return;
|
||||
const handler = e => {
|
||||
const $filterCell = $.closest('.data-table-cell', e.target);
|
||||
const {
|
||||
@ -46222,7 +46242,7 @@ class ColumnManager {
|
||||
this.rowmanager.showRows(rowsToShow);
|
||||
});
|
||||
};
|
||||
$.on(this.header, 'keydown', '.data-table-filter', debounce$1(handler, 300));
|
||||
$.on(this.header, 'keydown', '.data-table-filter', debounce$2(handler, 300));
|
||||
}
|
||||
|
||||
sortRows(colIndex, sortOrder) {
|
||||
@ -46237,18 +46257,16 @@ class ColumnManager {
|
||||
return this.datamanager.getColumns();
|
||||
}
|
||||
|
||||
setColumnWidth(colIndex) {
|
||||
setColumnWidth(colIndex, width) {
|
||||
colIndex = +colIndex;
|
||||
this._columnWidthMap = this._columnWidthMap || [];
|
||||
|
||||
const {
|
||||
width
|
||||
} = this.getColumn(colIndex);
|
||||
let columnWidth = width || this.getColumn(colIndex).width;
|
||||
|
||||
let index = this._columnWidthMap[colIndex];
|
||||
const selector = `[data-col-index="${colIndex}"] .content, [data-col-index="${colIndex}"] .edit-cell`;
|
||||
const styles = {
|
||||
width: width + 'px'
|
||||
width: columnWidth + 'px'
|
||||
};
|
||||
|
||||
index = this.style.setStyle(selector, styles, index);
|
||||
@ -46416,7 +46434,7 @@ class CellManager {
|
||||
this.deactivateEditing();
|
||||
});
|
||||
|
||||
if (this.options.enableInlineFilters) {
|
||||
if (this.options.inlineFilters) {
|
||||
this.keyboard.on('ctrl+f', (e) => {
|
||||
const $cell = $.closest('.data-table-cell', e.target);
|
||||
let {
|
||||
@ -47003,7 +47021,7 @@ class CellManager {
|
||||
contentHTML = cell.column.format(cell.content, row, cell.column, data);
|
||||
}
|
||||
|
||||
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||
if (this.options.treeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||
const nextRow = this.datamanager.getRow(cell.rowIndex + 1);
|
||||
const addToggle = nextRow && nextRow.meta.indent > cell.indent;
|
||||
|
||||
@ -47044,13 +47062,14 @@ class RowManager {
|
||||
this.instance = instance;
|
||||
linkProperties(this, this.instance, [
|
||||
'options',
|
||||
'fireEvent',
|
||||
'wrapper',
|
||||
'bodyScrollable',
|
||||
'bodyRenderer'
|
||||
]);
|
||||
|
||||
this.bindEvents();
|
||||
this.refreshRows = promisify(this.refreshRows, this);
|
||||
this.refreshRows = nextTick(this.refreshRows, this);
|
||||
}
|
||||
|
||||
get datamanager() {
|
||||
@ -47066,7 +47085,7 @@ class RowManager {
|
||||
}
|
||||
|
||||
bindCheckbox() {
|
||||
if (!this.options.addCheckboxColumn) return;
|
||||
if (!this.options.checkboxColumn) return;
|
||||
|
||||
// map of checked rows
|
||||
this.checkMap = [];
|
||||
@ -47135,6 +47154,7 @@ class RowManager {
|
||||
// highlight row
|
||||
this.highlightRow(rowIndex, toggle);
|
||||
this.showCheckStatus();
|
||||
this.fireEvent('onCheckRow', this.datamanager.getRow(rowIndex));
|
||||
}
|
||||
|
||||
checkAll(toggle) {
|
||||
@ -47157,9 +47177,11 @@ class RowManager {
|
||||
}
|
||||
|
||||
showCheckStatus() {
|
||||
if (!this.options.checkedRowStatus) return;
|
||||
const checkedRows = this.getCheckedRows();
|
||||
if (checkedRows.length > 0) {
|
||||
this.bodyRenderer.showToastMessage(checkedRows.length + ' rows selected');
|
||||
const count = checkedRows.length;
|
||||
if (count > 0) {
|
||||
this.bodyRenderer.showToastMessage(`${count} row${count > 1 ? 's' : ''} selected`);
|
||||
} else {
|
||||
this.bodyRenderer.clearToastMessage();
|
||||
}
|
||||
@ -47322,11 +47344,11 @@ class BodyRenderer {
|
||||
this.cellmanager = instance.cellmanager;
|
||||
this.bodyScrollable = instance.bodyScrollable;
|
||||
this.log = instance.log;
|
||||
this.appendRemainingData = promisify(this.appendRemainingData, this);
|
||||
this.appendRemainingData = nextTick(this.appendRemainingData, this);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.options.enableClusterize) {
|
||||
if (this.options.clusterize) {
|
||||
this.renderBodyWithClusterize();
|
||||
} else {
|
||||
this.renderBodyHTML();
|
||||
@ -47443,6 +47465,7 @@ class Style {
|
||||
$.on(window, 'resize', throttle$1(() => {
|
||||
this.distributeRemainingWidth();
|
||||
this.refreshColumnWidth();
|
||||
this.compensateScrollbarWidth();
|
||||
this.setBodyStyle();
|
||||
}, 300));
|
||||
}
|
||||
@ -47484,9 +47507,10 @@ class Style {
|
||||
this.setupMinWidth();
|
||||
this.setupNaturalColumnWidth();
|
||||
this.setupColumnWidth();
|
||||
|
||||
this.distributeRemainingWidth();
|
||||
this.setColumnStyle();
|
||||
this.compensateScrollbarWidth();
|
||||
|
||||
this.setDefaultCellHeight();
|
||||
this.setBodyStyle();
|
||||
}
|
||||
@ -47556,12 +47580,12 @@ class Style {
|
||||
if (this.options.layout === 'ratio') {
|
||||
let totalWidth = $.style(this.datatableWrapper, 'width');
|
||||
|
||||
if (this.options.addSerialNoColumn) {
|
||||
if (this.options.serialNoColumn) {
|
||||
const rowIndexColumn = this.datamanager.getColumnById('_rowIndex');
|
||||
totalWidth = totalWidth - rowIndexColumn.width - 1;
|
||||
}
|
||||
|
||||
if (this.options.addCheckboxColumn) {
|
||||
if (this.options.checkboxColumn) {
|
||||
const rowIndexColumn = this.datamanager.getColumnById('_checkbox');
|
||||
totalWidth = totalWidth - rowIndexColumn.width - 1;
|
||||
}
|
||||
@ -47599,6 +47623,13 @@ class Style {
|
||||
}
|
||||
}
|
||||
|
||||
compensateScrollbarWidth() {
|
||||
const scrollbarWidth = $.scrollbarWidth();
|
||||
const lastCol = this.datamanager.getColumn(-1);
|
||||
const width = lastCol.width - scrollbarWidth;
|
||||
this.columnmanager.setColumnWidth(lastCol.colIndex, width);
|
||||
}
|
||||
|
||||
distributeRemainingWidth() {
|
||||
if (this.options.layout !== 'fluid') return;
|
||||
|
||||
@ -47620,7 +47651,7 @@ class Style {
|
||||
setDefaultCellHeight() {
|
||||
if (this.__cellHeightSet) return;
|
||||
const height = this.options.cellHeight ||
|
||||
$.style($('.data-table-cell', this.instance.datatableWrapper), 'height');
|
||||
$.style($('.data-table-cell', this.instance.bodyScrollable), 'height');
|
||||
if (height) {
|
||||
this.setCellHeight(height);
|
||||
this.__cellHeightSet = true;
|
||||
@ -47780,12 +47811,19 @@ var DEFAULT_OPTIONS = {
|
||||
action: function (column) {
|
||||
this.removeColumn(column.colIndex);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Freeze column',
|
||||
action: function (column) {
|
||||
this.freezeColumn(column.colIndex);
|
||||
}
|
||||
}
|
||||
],
|
||||
events: {
|
||||
onRemoveColumn(column) {},
|
||||
onSwitchColumn(column1, column2) {},
|
||||
onSortColumn(column) {}
|
||||
onSortColumn(column) {},
|
||||
onCheckRow(row) {}
|
||||
},
|
||||
sortIndicator: {
|
||||
asc: '↑',
|
||||
@ -47794,15 +47832,16 @@ var DEFAULT_OPTIONS = {
|
||||
},
|
||||
freezeMessage: '',
|
||||
getEditor: null,
|
||||
addSerialNoColumn: true,
|
||||
addCheckboxColumn: false,
|
||||
enableClusterize: true,
|
||||
enableLogs: false,
|
||||
layout: 'ratio', // fixed, fluid, ratio
|
||||
serialNoColumn: true,
|
||||
checkboxColumn: false,
|
||||
clusterize: true,
|
||||
logs: false,
|
||||
layout: 'fixed', // fixed, fluid, ratio
|
||||
noDataMessage: 'No Data',
|
||||
cellHeight: null,
|
||||
enableInlineFilters: false,
|
||||
enableTreeView: false
|
||||
inlineFilters: false,
|
||||
treeView: false,
|
||||
checkedRowStatus: true
|
||||
};
|
||||
|
||||
class DataTable {
|
||||
@ -47818,14 +47857,7 @@ class DataTable {
|
||||
throw new Error('Invalid argument given for `wrapper`');
|
||||
}
|
||||
|
||||
this.options = Object.assign({}, DEFAULT_OPTIONS, options);
|
||||
this.options.headerDropdown =
|
||||
DEFAULT_OPTIONS.headerDropdown
|
||||
.concat(options.headerDropdown || []);
|
||||
// custom user events
|
||||
this.events = Object.assign({}, DEFAULT_OPTIONS.events, options.events || {});
|
||||
this.fireEvent = this.fireEvent.bind(this);
|
||||
|
||||
this.buildOptions(options);
|
||||
this.prepare();
|
||||
|
||||
this.style = new Style(this);
|
||||
@ -47841,6 +47873,26 @@ class DataTable {
|
||||
}
|
||||
}
|
||||
|
||||
buildOptions(options) {
|
||||
this.options = this.options || {};
|
||||
|
||||
this.options = Object.assign(
|
||||
{}, DEFAULT_OPTIONS,
|
||||
this.options || {}, options
|
||||
);
|
||||
|
||||
this.options.headerDropdown
|
||||
.push(...(options.headerDropdown || []));
|
||||
|
||||
// custom user events
|
||||
this.events = Object.assign(
|
||||
{}, DEFAULT_OPTIONS.events,
|
||||
this.options.events || {},
|
||||
options.events || {}
|
||||
);
|
||||
this.fireEvent = this.fireEvent.bind(this);
|
||||
}
|
||||
|
||||
prepare() {
|
||||
this.prepareDom();
|
||||
this.unfreeze();
|
||||
@ -47860,6 +47912,8 @@ class DataTable {
|
||||
</div>
|
||||
<div class="toast-message"></div>
|
||||
</div>
|
||||
<div class="data-table-fixed-columns">
|
||||
</div>
|
||||
`;
|
||||
|
||||
this.datatableWrapper = $('.data-table', this.wrapper);
|
||||
@ -47867,6 +47921,7 @@ class DataTable {
|
||||
this.bodyScrollable = $('.body-scrollable', this.wrapper);
|
||||
this.freezeContainer = $('.freeze-container', this.wrapper);
|
||||
this.toastMessage = $('.toast-message', this.wrapper);
|
||||
this.fixedColumnsWrapper = $('.data-table-fixed-columns', this.wrapper);
|
||||
}
|
||||
|
||||
refresh(data, columns) {
|
||||
@ -47950,6 +48005,10 @@ class DataTable {
|
||||
this.columnmanager.removeColumn(colIndex);
|
||||
}
|
||||
|
||||
freezeColumn(colIndex) {
|
||||
this.columnmanager.freezeColumn(colIndex);
|
||||
}
|
||||
|
||||
scrollToLastColumn() {
|
||||
this.datatableWrapper.scrollLeft = 9999;
|
||||
}
|
||||
@ -47966,12 +48025,16 @@ class DataTable {
|
||||
});
|
||||
}
|
||||
|
||||
updateOptions(options) {
|
||||
this.buildOptions(options);
|
||||
}
|
||||
|
||||
fireEvent(eventName, ...args) {
|
||||
this.events[eventName].apply(this, args);
|
||||
}
|
||||
|
||||
log() {
|
||||
if (this.options.enableLogs) {
|
||||
if (this.options.logs) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
@ -47980,10 +48043,10 @@ class DataTable {
|
||||
DataTable.instances = 0;
|
||||
|
||||
var name = "frappe-datatable";
|
||||
var version = "0.0.2";
|
||||
var version = "0.0.3";
|
||||
var description = "A modern datatable library for the web";
|
||||
var main = "dist/frappe-datatable.cjs.js";
|
||||
var scripts = {"start":"npm run dev","build":"rollup -c","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"};
|
||||
var scripts = {"start":"yarn run dev","build":"rollup -c","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"};
|
||||
var devDependencies = {"chai":"3.5.0","cssnano":"^3.10.0","deepmerge":"^2.0.1","eslint":"3.19.0","eslint-loader":"1.7.1","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","precss":"^3.1.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify":"^3.0.0"};
|
||||
var repository = {"type":"git","url":"https://github.com/frappe/datatable.git"};
|
||||
var keywords = ["datatable","data","grid","table"];
|
||||
@ -56579,11 +56642,13 @@ var tablepage = class TablePage extends page {
|
||||
constructor(doctype) {
|
||||
let meta = frappejs.getMeta(doctype);
|
||||
super({title: `${meta.label || meta.name}`, hasRoute: true});
|
||||
this.filterWrapper = frappejs.ui.add('div', 'filter-toolbar', this.body);
|
||||
this.fitlerButton = frappejs.ui.add('button', 'btn btn-sm btn-outline-secondary', this.filterWrapper, 'Set Filters');
|
||||
this.tableWrapper = frappejs.ui.add('div', 'table-page-wrapper', this.body);
|
||||
this.doctype = doctype;
|
||||
this.fullPage = true;
|
||||
|
||||
this.addButton('Set Filters', 'btn-secondary', async () => {
|
||||
this.fitlerButton.addEventListener('click', async () => {
|
||||
const formModal = await frappejs.desk.showFormModal('FilterSelector');
|
||||
formModal.form.once('apply-filters', () => {
|
||||
formModal.hide();
|
||||
@ -56601,6 +56666,11 @@ var tablepage = class TablePage extends page {
|
||||
this.filterSelector.reset(this.doctype);
|
||||
}
|
||||
|
||||
if (frappejs.flags.filters) {
|
||||
this.filterSelector.setFilters(frappejs.flags.filters);
|
||||
frappejs.flags.filters = null;
|
||||
}
|
||||
|
||||
if (!this.modelTable) {
|
||||
this.modelTable = new modelTable({
|
||||
doctype: this.doctype,
|
||||
@ -56613,6 +56683,7 @@ var tablepage = class TablePage extends page {
|
||||
}
|
||||
|
||||
async run() {
|
||||
this.displayFilters();
|
||||
const data = await frappejs.db.getAll({
|
||||
doctype: this.doctype,
|
||||
fields: ['*'],
|
||||
@ -56622,6 +56693,10 @@ var tablepage = class TablePage extends page {
|
||||
});
|
||||
this.modelTable.refresh(data);
|
||||
}
|
||||
|
||||
displayFilters() {
|
||||
this.fitlerButton.textContent = this.filterSelector.getText();
|
||||
}
|
||||
};
|
||||
|
||||
var menu = class DeskMenu {
|
||||
@ -56906,7 +56981,9 @@ var FilterGroup = {
|
||||
|
||||
var FilterSelectorDocument = class FormSelector extends document$1 {
|
||||
reset(doctype) {
|
||||
this.forDocType = doctype;
|
||||
if (doctype) {
|
||||
this.forDocType = doctype;
|
||||
}
|
||||
this.items = [];
|
||||
this.filterGroup = '';
|
||||
this.filterGroupName = '';
|
||||
@ -56915,12 +56992,33 @@ var FilterSelectorDocument = class FormSelector extends document$1 {
|
||||
getFilters() {
|
||||
const filters = {};
|
||||
for (let item of (this.items || [])) {
|
||||
if (item.condition === 'Equals') item.condition = '=';
|
||||
filters[item.field] = [item.condition, item.value];
|
||||
filters[item.field] = [(item.condition === 'Equals') ? '=' : item.condition,
|
||||
item.value];
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
setFilters(filters) {
|
||||
this.reset();
|
||||
for (let key in filters) {
|
||||
let value = filters[key];
|
||||
if (value instanceof Array) {
|
||||
this.items.push({field: key, condition: value[0], value: value[1]});
|
||||
} else {
|
||||
this.items.push({field: key, condition: 'Equals', value: value});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getText() {
|
||||
if (this.items && this.items.length) {
|
||||
this.forMeta = frappejs.getMeta(this.forDocType);
|
||||
return this.items.map(v => `${this.forMeta.getLabel(v.field)} ${v.condition} ${v.value}`).join(', ');
|
||||
} else {
|
||||
return 'Set Filters';
|
||||
}
|
||||
}
|
||||
|
||||
async update() {
|
||||
// save new group filter
|
||||
if (frappejs.isServer) {
|
||||
@ -58000,6 +58098,7 @@ var CustomerList_1 = class CustomerList extends list {
|
||||
}
|
||||
};
|
||||
|
||||
// start server
|
||||
client.start({
|
||||
columns: 3,
|
||||
server: 'localhost:8000'
|
||||
|
33
electron/client.js
Normal file
33
electron/client.js
Normal file
@ -0,0 +1,33 @@
|
||||
const client = require('frappejs/client/electron');
|
||||
|
||||
// start server
|
||||
client.start({
|
||||
dbPath: 'test.db',
|
||||
columns: 3
|
||||
}).then(() => {
|
||||
|
||||
// require modules
|
||||
frappe.registerModels(require('../models'), 'client');
|
||||
|
||||
frappe.registerView('List', 'ToDo', require('frappejs/models/doctype/ToDo/ToDoList.js'));
|
||||
frappe.registerView('Form', 'FilterSelector', require('frappejs/models/doctype/FilterSelector/FilterSelectorForm.js'));
|
||||
|
||||
frappe.registerView('List', 'Account', require('../models/doctype/Account/AccountList.js'));
|
||||
frappe.registerView('Form', 'Account', require('../models/doctype/Account/AccountForm.js'));
|
||||
|
||||
frappe.registerView('List', 'Invoice', require('../models/doctype/Invoice/InvoiceList.js'));
|
||||
frappe.registerView('List', 'Customer', require('../models/doctype/Party/CustomerList.js'));
|
||||
|
||||
frappe.desk.menu.addItem('ToDo', '#list/ToDo');
|
||||
frappe.desk.menu.addItem('Accounts', '#list/Account');
|
||||
frappe.desk.menu.addItem('Items', '#list/Item');
|
||||
frappe.desk.menu.addItem('Customers', '#list/Customer');
|
||||
frappe.desk.menu.addItem('Invoice', '#list/Invoice');
|
||||
frappe.desk.menu.addItem('Settings', () => frappe.desk.showFormModal('SystemSettings'));
|
||||
|
||||
frappe.router.default = '#list/ToDo';
|
||||
|
||||
frappe.router.show(window.location.hash);
|
||||
});
|
||||
|
||||
module.exports = false;
|
12
electron/index.html
Normal file
12
electron/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link href="../dist/css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<script src="./client.js"></script>
|
||||
</body>
|
||||
</html>
|
60
electron/main.js
Normal file
60
electron/main.js
Normal file
@ -0,0 +1,60 @@
|
||||
const electron = require('electron')
|
||||
// Module to control application life.
|
||||
const app = electron.app
|
||||
// Module to create native browser window.
|
||||
const BrowserWindow = electron.BrowserWindow
|
||||
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({width: 800, height: 600})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools()
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function () {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow)
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', function () {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (mainWindow === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
17
package.json
17
package.json
@ -1,15 +1,26 @@
|
||||
{
|
||||
"name": "frappe-accounting",
|
||||
"productName": "ERPNext Desktop",
|
||||
"version": "1.0.0",
|
||||
"main": "server.js",
|
||||
"main": "electron/main.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "mocha tests",
|
||||
"start": "nodemon server.js"
|
||||
"start": "nodemon server.js",
|
||||
"watch": "rollup -c --watch",
|
||||
"start-electron": "electron electron/main.js",
|
||||
"electron-dev": "yarn run start-electron & yarn run watch",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"electron-pack": "electron-packager . --overwrite"
|
||||
},
|
||||
"dependencies": {
|
||||
"frappejs": "link:../frappejs"
|
||||
"frappejs": "^0.0.5",
|
||||
"nunjucks": "^3.1.2",
|
||||
"sqlite3": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "1.8.4",
|
||||
"electron-builder": "^20.6.2",
|
||||
"electron-packager": "^11.2.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user