Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

admin-config

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

admin-config - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

lib/Application.js.map

435

lib/Application.js

@@ -1,228 +0,291 @@

import Menu from './Menu/Menu';
import Collection from './Collection';
import Dashboard from './Dashboard';
import orderElement from "./Utils/orderElement";
'use strict';
class Application {
constructor(title='ng-admin', debug=true) {
this._baseApiUrl = '';
this._customTemplate = function(viewName) {};
this._title = title;
this._menu = null;
this._dashboard = null;
this._layout = false;
this._header = false;
this._entities = [];
this._errorMessage = this.defaultErrorMessage;
this._debug = debug;
}
Object.defineProperty(exports, '__esModule', {
value: true
});
defaultErrorMessage(response) {
let body = response.data;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
if (typeof body === 'object') {
body = JSON.stringify(body);
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
return 'Oops, an error occured : (code: ' + response.status + ') ' + body;
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
get entities() {
return this._entities;
}
var _MenuMenu = require('./Menu/Menu');
getViewsOfType(type) {
return orderElement.order(
this.entities.map(entity => entity.views[type])
.filter(view => view.enabled)
);
}
var _MenuMenu2 = _interopRequireDefault(_MenuMenu);
getRouteFor(entity, viewUrl, viewType, identifierValue, identifierName) {
let baseApiUrl = entity.baseApiUrl() || this.baseApiUrl(),
url = viewUrl || entity.getUrl(viewType, identifierValue, identifierName);
var _Collection = require('./Collection');
// If the view or the entity don't define the url, retrieve it from the baseURL of the entity or the app
if (!url) {
url = baseApiUrl + encodeURIComponent(entity.name());
if (identifierValue != null) {
url += '/' + encodeURIComponent(identifierValue);
}
} else if (!/^(?:[a-z]+:)?\/\//.test(url)) {
// Add baseUrl for relative URL
url = baseApiUrl + url;
}
var _Collection2 = _interopRequireDefault(_Collection);
return url;
}
var _Dashboard = require('./Dashboard');
debug(debug) {
if (!arguments.length) return this._debug;
this._debug = debug;
return this;
}
var _Dashboard2 = _interopRequireDefault(_Dashboard);
layout(layout) {
if (!arguments.length) return this._layout;
this._layout = layout;
return this;
}
var _UtilsOrderElement = require('./Utils/orderElement');
header(header) {
if (!arguments.length) return this._header;
this._header = header;
return this;
}
var _UtilsOrderElement2 = _interopRequireDefault(_UtilsOrderElement);
title(title) {
if (!arguments.length) return this._title;
var Application = (function () {
function Application() {
var title = arguments[0] === undefined ? 'ng-admin' : arguments[0];
var debug = arguments[1] === undefined ? true : arguments[1];
_classCallCheck(this, Application);
this._baseApiUrl = '';
this._customTemplate = function (viewName) {};
this._title = title;
return this;
this._menu = null;
this._dashboard = null;
this._layout = false;
this._header = false;
this._entities = [];
this._errorMessage = this.defaultErrorMessage;
this._debug = debug;
}
/**
* Getter/Setter for the main application menu
*
* If the getter is called first, it will return a menu based on entities.
*
* application.addEntity(new Entity('posts'));
* application.addEntity(new Entity('comments'));
* application.menu(); // Menu { children: [ Menu { title: "Posts" }, Menu { title: "Comments" } ]}
*
* If the setter is called first, all subsequent calls to the getter will return the set menu.
*
* application.addEntity(new Entity('posts'));
* application.addEntity(new Entity('comments'));
* application.menu(new Menu().addChild(new Menu().title('Foo')));
* application.menu(); // Menu { children: [ Menu { title: "Foo" } ]}
*
* @see Menu
*/
menu(menu) {
if (!arguments.length) {
if (!this._menu) {
this._menu = this.buildMenuFromEntities();
_createClass(Application, [{
key: 'defaultErrorMessage',
value: function defaultErrorMessage(response) {
var body = response.data;
if (typeof body === 'object') {
body = JSON.stringify(body);
}
return this._menu
return 'Oops, an error occured : (code: ' + response.status + ') ' + body;
}
}, {
key: 'getViewsOfType',
value: function getViewsOfType(type) {
return _UtilsOrderElement2['default'].order(this.entities.map(function (entity) {
return entity.views[type];
}).filter(function (view) {
return view.enabled;
}));
}
}, {
key: 'getRouteFor',
value: function getRouteFor(entity, viewUrl, viewType, identifierValue, identifierName) {
var baseApiUrl = entity.baseApiUrl() || this.baseApiUrl(),
url = viewUrl || entity.getUrl(viewType, identifierValue, identifierName);
this._menu = menu;
return this;
}
// If the view or the entity don't define the url, retrieve it from the baseURL of the entity or the app
if (!url) {
url = baseApiUrl + encodeURIComponent(entity.name());
if (identifierValue != null) {
url += '/' + encodeURIComponent(identifierValue);
}
} else if (!/^(?:[a-z]+:)?\/\//.test(url)) {
// Add baseUrl for relative URL
url = baseApiUrl + url;
}
buildMenuFromEntities() {
return new Menu().children(
this.entities
.filter(entity => entity.menuView().enabled)
.sort((e1, e2) => e1.menuView().order() - e2.menuView().order())
.map(entity => new Menu().populateFromEntity(entity))
);
}
return url;
}
}, {
key: 'debug',
value: function debug(_debug) {
if (!arguments.length) return this._debug;
this._debug = _debug;
return this;
}
}, {
key: 'layout',
value: function layout(_layout) {
if (!arguments.length) return this._layout;
this._layout = _layout;
return this;
}
}, {
key: 'header',
value: function header(_header) {
if (!arguments.length) return this._header;
this._header = _header;
return this;
}
}, {
key: 'title',
value: function title(_title) {
if (!arguments.length) return this._title;
this._title = _title;
return this;
}
}, {
key: 'menu',
dashboard(dashboard) {
if (!arguments.length) {
/**
* Getter/Setter for the main application menu
*
* If the getter is called first, it will return a menu based on entities.
*
* application.addEntity(new Entity('posts'));
* application.addEntity(new Entity('comments'));
* application.menu(); // Menu { children: [ Menu { title: "Posts" }, Menu { title: "Comments" } ]}
*
* If the setter is called first, all subsequent calls to the getter will return the set menu.
*
* application.addEntity(new Entity('posts'));
* application.addEntity(new Entity('comments'));
* application.menu(new Menu().addChild(new Menu().title('Foo')));
* application.menu(); // Menu { children: [ Menu { title: "Foo" } ]}
*
* @see Menu
*/
value: function menu(_menu) {
if (!arguments.length) {
if (!this._menu) {
this._menu = this.buildMenuFromEntities();
}
return this._menu;
}
this._menu = _menu;
return this;
}
}, {
key: 'buildMenuFromEntities',
value: function buildMenuFromEntities() {
return new _MenuMenu2['default']().children(this.entities.filter(function (entity) {
return entity.menuView().enabled;
}).sort(function (e1, e2) {
return e1.menuView().order() - e2.menuView().order();
}).map(function (entity) {
return new _MenuMenu2['default']().populateFromEntity(entity);
}));
}
}, {
key: 'dashboard',
value: function dashboard(_dashboard) {
if (!arguments.length) {
if (!this._dashboard) {
this._dashboard = this.buildDashboardFromEntities();
}
return this._dashboard
return this._dashboard;
}
this._dashboard = _dashboard;
return this;
}
this._dashboard = dashboard;
return this;
}
buildDashboardFromEntities() {
let dashboard = new Dashboard()
this.entities
.filter(entity => entity.dashboardView().enabled)
.map(entity => {
}, {
key: 'buildDashboardFromEntities',
value: function buildDashboardFromEntities() {
var dashboard = new _Dashboard2['default']();
this.entities.filter(function (entity) {
return entity.dashboardView().enabled;
}).map(function (entity) {
dashboard.addCollection(entity.dashboardView()); // yep, a collection is a ListView, and so is a DashboardView - forgive this duck typing for BC sake
});
if (!dashboard.hasCollections()) {
// still no collection from dashboardViews, let's use listViews instead
this.entities
.filter(entity => entity.listView().enabled)
.map((entity, index) => {
let collection = new Collection();
let listView = entity.listView();
if (!dashboard.hasCollections()) {
// still no collection from dashboardViews, let's use listViews instead
this.entities.filter(function (entity) {
return entity.listView().enabled;
}).map(function (entity, index) {
var collection = new _Collection2['default']();
var listView = entity.listView();
collection.setEntity(entity);
collection.perPage(listView.perPage())
collection.sortField(listView.sortField())
collection.sortDir(listView.sortDir())
collection.perPage(listView.perPage());
collection.sortField(listView.sortField());
collection.sortDir(listView.sortDir());
collection.order(index);
// use only the first 3 cols
collection.fields(listView.fields().filter((el, index) => index < 3));
collection.fields(listView.fields().filter(function (el, index) {
return index < 3;
}));
dashboard.addCollection(collection);
});
}
return dashboard;
}
return dashboard;
}
}, {
key: 'customTemplate',
value: function customTemplate(_customTemplate) {
if (!arguments.length) return this._customTemplate;
this._customTemplate = _customTemplate;
return this;
}
}, {
key: 'baseApiUrl',
value: function baseApiUrl(url) {
if (!arguments.length) return this._baseApiUrl;
this._baseApiUrl = url;
return this;
}
}, {
key: 'addEntity',
value: function addEntity(entity) {
if (!entity) {
throw new Error('No entity given');
}
customTemplate(customTemplate) {
if (!arguments.length) return this._customTemplate;
this._customTemplate = customTemplate;
return this;
}
this._entities.push(entity);
baseApiUrl(url) {
if (!arguments.length) return this._baseApiUrl;
this._baseApiUrl = url;
return this;
}
addEntity(entity) {
if (!entity) {
throw new Error("No entity given");
return this;
}
}, {
key: 'getEntity',
value: function getEntity(entityName) {
var foundEntity = this._entities.filter(function (e) {
return e.name() === entityName;
})[0];
if (!foundEntity) {
throw new Error('Unable to find entity "' + entityName + '"');
}
this._entities.push(entity);
return this;
}
getEntity(entityName) {
let foundEntity = this._entities.filter(e => e.name() === entityName)[0];
if (!foundEntity) {
throw new Error(`Unable to find entity "${entityName}"`);
return foundEntity;
}
}, {
key: 'hasEntity',
value: function hasEntity(fieldName) {
return !!this._entities.filter(function (f) {
return f.name() === fieldName;
}).length;
}
}, {
key: 'getViewByEntityAndType',
value: function getViewByEntityAndType(entityName, type) {
return this._entities.filter(function (e) {
return e.name() === entityName;
})[0].views[type];
}
}, {
key: 'getErrorMessage',
value: function getErrorMessage(response) {
if (typeof this._errorMessage === 'function') {
return this._errorMessage(response);
}
return foundEntity;
}
hasEntity(fieldName) {
return !!(this._entities.filter(f => f.name() === fieldName).length);
}
getViewByEntityAndType(entityName, type) {
return this._entities
.filter(e => e.name() === entityName)[0]
.views[type];
}
getErrorMessage(response) {
if (typeof(this._errorMessage) === 'function') {
return this._errorMessage(response);
return this._errorMessage;
}
}, {
key: 'errorMessage',
value: function errorMessage(_errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = _errorMessage;
return this;
}
}, {
key: 'getErrorMessageFor',
value: function getErrorMessageFor(view, response) {
return view.getErrorMessage(response) || view.getEntity().getErrorMessage(response) || this.getErrorMessage(response);
}
}, {
key: 'getEntityNames',
value: function getEntityNames() {
return this.entities.map(function (f) {
return f.name();
});
}
}, {
key: 'entities',
get: function () {
return this._entities;
}
}]);
return this._errorMessage;
}
return Application;
})();
errorMessage(errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = errorMessage;
return this;
}
getErrorMessageFor(view, response) {
return (
view.getErrorMessage(response)
|| view.getEntity().getErrorMessage(response)
|| this.getErrorMessage(response)
);
}
getEntityNames() {
return this.entities.map(f => f.name());
}
}
export default Application;
exports['default'] = Application;
module.exports = exports['default'];
//# sourceMappingURL=Application.js.map

@@ -1,14 +0,46 @@

import ListView from './View/ListView';
'use strict';
class Collection extends ListView {
Object.defineProperty(exports, '__esModule', {
value: true
});
setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name();
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ViewListView = require('./View/ListView');
var _ViewListView2 = _interopRequireDefault(_ViewListView);
var Collection = (function (_ListView) {
function Collection() {
_classCallCheck(this, Collection);
if (_ListView != null) {
_ListView.apply(this, arguments);
}
return this;
}
}
export default Collection;
_inherits(Collection, _ListView);
_createClass(Collection, [{
key: 'setEntity',
value: function setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name();
}
return this;
}
}]);
return Collection;
})(_ViewListView2['default']);
exports['default'] = Collection;
module.exports = exports['default'];
//# sourceMappingURL=Collection.js.map

@@ -1,3 +0,15 @@

class Dashboard {
constructor() {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Dashboard = (function () {
function Dashboard() {
_classCallCheck(this, Dashboard);
this._collections = {};

@@ -7,28 +19,38 @@ this._template = null;

addCollection(collection) {
this._collections[collection.name()] = collection;
return this;
}
collections(collections) {
if (arguments.length) {
this._collections = collections;
_createClass(Dashboard, [{
key: "addCollection",
value: function addCollection(collection) {
this._collections[collection.name()] = collection;
return this;
}
return this._collections;
}
}, {
key: "collections",
value: function collections(_collections) {
if (arguments.length) {
this._collections = _collections;
return this;
}
return this._collections;
}
}, {
key: "hasCollections",
value: function hasCollections() {
return Object.keys(this._collections).length > 0;
}
}, {
key: "template",
value: function template(_template) {
if (arguments.length) {
this._template = _template;
return this;
}
return this._template;
}
}]);
hasCollections() {
return Object.keys(this._collections).length > 0;
}
return Dashboard;
})();
template(template) {
if (arguments.length) {
this._template = template;
return this;
}
return this._template;
}
}
export default Dashboard;
exports["default"] = Dashboard;
module.exports = exports["default"];
//# sourceMappingURL=Dashboard.js.map

@@ -1,94 +0,123 @@

class DataStore {
constructor() {
this._entries = {};
}
'use strict';
setEntries(name, entries) {
this._entries[name] = entries;
Object.defineProperty(exports, '__esModule', {
value: true
});
return this;
}
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
addEntry(name, entry) {
if (!(name in this._entries)) {
this._entries[name] = [];
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
this._entries[name].push(entry);
}
var DataStore = (function () {
function DataStore() {
_classCallCheck(this, DataStore);
getEntries(name) {
return this._entries[name] || [];
this._entries = {};
}
/**
* Get first entry satisfying a filter function
*
* @example datastore.getEntry('books', book => book.title === 'War and Peace');
*/
getFirstEntry(name, filter = () => true) {
return this.getEntries(name)
.filter(filter)
.shift();
}
_createClass(DataStore, [{
key: 'setEntries',
value: function setEntries(name, entries) {
this._entries[name] = entries;
getChoices(field) {
let identifier = field.targetEntity().identifier().name();
let name = field.targetField().name();
return this;
}
}, {
key: 'addEntry',
value: function addEntry(name, entry) {
if (!(name in this._entries)) {
this._entries[name] = [];
}
return this.getEntries(field.targetEntity().uniqueId + '_choices').map(function(entry) {
return {
value: entry.values[identifier],
label: entry.values[name]
};
});
}
this._entries[name].push(entry);
}
}, {
key: 'getEntries',
value: function getEntries(name) {
return this._entries[name] || [];
}
}, {
key: 'getFirstEntry',
fillReferencesValuesFromCollection(collection, referencedValues, fillSimpleReference) {
fillSimpleReference = typeof (fillSimpleReference) === 'undefined' ? false : fillSimpleReference;
/**
* Get first entry satisfying a filter function
*
* @example datastore.getEntry('books', book => book.title === 'War and Peace');
*/
value: function getFirstEntry(name) {
var filter = arguments[1] === undefined ? function () {
return true;
} : arguments[1];
for (let i = 0, l = collection.length; i < l; i++) {
collection[i] = this.fillReferencesValuesFromEntry(collection[i], referencedValues, fillSimpleReference);
return this.getEntries(name).filter(filter).shift();
}
}, {
key: 'getChoices',
value: function getChoices(field) {
var identifier = field.targetEntity().identifier().name();
var name = field.targetField().name();
return collection;
}
return this.getEntries(field.targetEntity().uniqueId + '_choices').map(function (entry) {
return {
value: entry.values[identifier],
label: entry.values[name]
};
});
}
}, {
key: 'fillReferencesValuesFromCollection',
value: function fillReferencesValuesFromCollection(collection, referencedValues, fillSimpleReference) {
fillSimpleReference = typeof fillSimpleReference === 'undefined' ? false : fillSimpleReference;
fillReferencesValuesFromEntry(entry, referencedValues, fillSimpleReference) {
for (let referenceField in referencedValues) {
let reference = referencedValues[referenceField],
choices = this.getReferenceChoicesById(reference),
entries = [],
identifier = reference.getMappedValue(entry.values[referenceField], entry.values);
for (var i = 0, l = collection.length; i < l; i++) {
collection[i] = this.fillReferencesValuesFromEntry(collection[i], referencedValues, fillSimpleReference);
}
if (reference.type() === 'reference_many') {
for (let i in identifier) {
let id = identifier[i];
entries.push(choices[id]);
return collection;
}
}, {
key: 'fillReferencesValuesFromEntry',
value: function fillReferencesValuesFromEntry(entry, referencedValues, fillSimpleReference) {
for (var referenceField in referencedValues) {
var reference = referencedValues[referenceField],
choices = this.getReferenceChoicesById(reference),
entries = [],
identifier = reference.getMappedValue(entry.values[referenceField], entry.values);
if (reference.type() === 'reference_many') {
for (var i in identifier) {
var id = identifier[i];
entries.push(choices[id]);
}
entry.listValues[referenceField] = entries;
} else if (fillSimpleReference && identifier != null && identifier in choices) {
entry.listValues[referenceField] = reference.getMappedValue(choices[identifier], entry.values);
}
}
entry.listValues[referenceField] = entries;
} else if (fillSimpleReference && identifier != null && identifier in choices) {
entry.listValues[referenceField] = reference.getMappedValue(choices[identifier], entry.values);
}
return entry;
}
}, {
key: 'getReferenceChoicesById',
value: function getReferenceChoicesById(field) {
var result = {},
targetField = field.targetField().name(),
targetIdentifier = field.targetEntity().identifier().name(),
entries = this.getEntries(field.targetEntity().uniqueId + '_values');
return entry;
}
for (var i = 0, l = entries.length; i < l; i++) {
var entry = entries[i];
result[entry.values[targetIdentifier]] = entry.values[targetField];
}
getReferenceChoicesById(field) {
let result = {},
targetField = field.targetField().name(),
targetIdentifier = field.targetEntity().identifier().name(),
entries = this.getEntries(field.targetEntity().uniqueId + '_values');
for (let i = 0, l = entries.length ; i < l ; i++) {
let entry = entries[i];
result[entry.values[targetIdentifier]] = entry.values[targetField];
return result;
}
}]);
return result;
}
}
return DataStore;
})();
export default DataStore;
exports['default'] = DataStore;
module.exports = exports['default'];
//# sourceMappingURL=DataStore.js.map

@@ -1,204 +0,282 @@

import stringUtils from "../Utils/stringUtils";
import Field from "../Field/Field";
import DashboardView from '../View/DashboardView';
import MenuView from '../View/MenuView';
import ListView from '../View/ListView';
import CreateView from '../View/CreateView';
import EditView from '../View/EditView';
import DeleteView from '../View/DeleteView';
import ShowView from '../View/ShowView';
import BatchDeleteView from '../View/BatchDeleteView';
import ExportView from '../View/ExportView';
"use strict";
var index = 0;
Object.defineProperty(exports, "__esModule", {
value: true
});
class Entity {
constructor(name) {
this._name = name;
this._uniqueId = this._name + '_' + index++;
this._baseApiUrl = null;
this._label = null;
this._identifierField = new Field("id");
this._isReadOnly = false;
this._errorMessage = null;
this._order = 0;
this._url = null;
this._createMethod = null; // manually set the HTTP-method for create operation, defaults to post
this._updateMethod = null; // manually set the HTTP-method for update operation, defaults to put
this._retrieveMethod = null; // manually set the HTTP-method for the get operation, defaults to get
this._deleteMethod = null; // manually set the HTTP-method for the delete operation, defaults to delete
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
this._initViews();
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
get uniqueId() {
return this._uniqueId;
}
var _UtilsStringUtils = require("../Utils/stringUtils");
get views() {
return this._views;
}
var _UtilsStringUtils2 = _interopRequireDefault(_UtilsStringUtils);
label() {
if (arguments.length) {
this._label = arguments[0];
return this;
}
var _FieldField = require("../Field/Field");
if (this._label === null) {
return stringUtils.camelCase(this._name);
}
var _FieldField2 = _interopRequireDefault(_FieldField);
return this._label;
}
var _ViewDashboardView = require("../View/DashboardView");
name() {
if (arguments.length) {
this._name = arguments[0];
return this;
}
var _ViewDashboardView2 = _interopRequireDefault(_ViewDashboardView);
return this._name;
}
var _ViewMenuView = require("../View/MenuView");
menuView() {
return this._views["MenuView"];
}
var _ViewMenuView2 = _interopRequireDefault(_ViewMenuView);
dashboardView() {
return this._views["DashboardView"];
}
var _ViewListView = require("../View/ListView");
listView() {
return this._views["ListView"];
}
var _ViewListView2 = _interopRequireDefault(_ViewListView);
creationView() {
return this._views["CreateView"];
}
var _ViewCreateView = require("../View/CreateView");
editionView() {
return this._views["EditView"];
}
var _ViewCreateView2 = _interopRequireDefault(_ViewCreateView);
deletionView() {
return this._views["DeleteView"];
}
var _ViewEditView = require("../View/EditView");
batchDeleteView() {
return this._views["BatchDeleteView"];
}
var _ViewEditView2 = _interopRequireDefault(_ViewEditView);
exportView() {
return this._views["ExportView"];
}
var _ViewDeleteView = require("../View/DeleteView");
showView() {
return this._views["ShowView"];
}
var _ViewDeleteView2 = _interopRequireDefault(_ViewDeleteView);
baseApiUrl(baseApiUrl) {
if (!arguments.length) return this._baseApiUrl;
this._baseApiUrl = baseApiUrl;
return this;
}
var _ViewShowView = require("../View/ShowView");
_initViews() {
this._views = {
"DashboardView": new DashboardView().setEntity(this),
"MenuView": new MenuView().setEntity(this),
"ListView": new ListView().setEntity(this),
"CreateView": new CreateView().setEntity(this),
"EditView": new EditView().setEntity(this),
"DeleteView": new DeleteView().setEntity(this),
"BatchDeleteView": new BatchDeleteView().setEntity(this),
"ExportView": new ExportView().setEntity(this),
"ShowView": new ShowView().setEntity(this)
};
}
var _ViewShowView2 = _interopRequireDefault(_ViewShowView);
identifier(value) {
if (!arguments.length) return this._identifierField;
if (!(value instanceof Field)) {
throw new Error('Entity ' + this.name() + ': identifier must be an instance of Field.');
}
this._identifierField = value;
return this;
}
var _ViewBatchDeleteView = require("../View/BatchDeleteView");
readOnly() {
this._isReadOnly = true;
var _ViewBatchDeleteView2 = _interopRequireDefault(_ViewBatchDeleteView);
this._views["CreateView"].disable();
this._views["EditView"].disable();
this._views["DeleteView"].disable();
this._views["BatchDeleteView"].disable();
var _ViewExportView = require("../View/ExportView");
return this;
}
var _ViewExportView2 = _interopRequireDefault(_ViewExportView);
get isReadOnly() {
return this._isReadOnly;
}
var index = 0;
getErrorMessage(response) {
if (typeof(this._errorMessage) === 'function') {
return this._errorMessage(response);
}
var Entity = (function () {
function Entity(name) {
_classCallCheck(this, Entity);
return this._errorMessage;
}
this._name = name;
this._uniqueId = this._name + "_" + index++;
this._baseApiUrl = null;
this._label = null;
this._identifierField = new _FieldField2["default"]("id");
this._isReadOnly = false;
this._errorMessage = null;
this._order = 0;
this._url = null;
this._createMethod = null; // manually set the HTTP-method for create operation, defaults to post
this._updateMethod = null; // manually set the HTTP-method for update operation, defaults to put
this._retrieveMethod = null; // manually set the HTTP-method for the get operation, defaults to get
this._deleteMethod = null; // manually set the HTTP-method for the delete operation, defaults to delete
errorMessage(errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = errorMessage;
return this;
this._initViews();
}
order(order) {
if (!arguments.length) return this._order;
this._order = order;
return this;
}
_createClass(Entity, [{
key: "label",
value: function label() {
if (arguments.length) {
this._label = arguments[0];
return this;
}
url(url) {
if (!arguments.length) return this._url;
this._url = url;
return this;
}
if (this._label === null) {
return _UtilsStringUtils2["default"].camelCase(this._name);
}
getUrl(viewType, identifierValue, identifierName) {
if (typeof(this._url) === 'function') {
return this._url(this.name(), viewType, identifierValue, identifierName);
return this._label;
}
}, {
key: "name",
value: function name() {
if (arguments.length) {
this._name = arguments[0];
return this;
}
return this._url;
}
return this._name;
}
}, {
key: "menuView",
value: function menuView() {
return this._views["MenuView"];
}
}, {
key: "dashboardView",
value: function dashboardView() {
return this._views["DashboardView"];
}
}, {
key: "listView",
value: function listView() {
return this._views["ListView"];
}
}, {
key: "creationView",
value: function creationView() {
return this._views["CreateView"];
}
}, {
key: "editionView",
value: function editionView() {
return this._views["EditView"];
}
}, {
key: "deletionView",
value: function deletionView() {
return this._views["DeleteView"];
}
}, {
key: "batchDeleteView",
value: function batchDeleteView() {
return this._views["BatchDeleteView"];
}
}, {
key: "exportView",
value: function exportView() {
return this._views["ExportView"];
}
}, {
key: "showView",
value: function showView() {
return this._views["ShowView"];
}
}, {
key: "baseApiUrl",
value: function baseApiUrl(_baseApiUrl) {
if (!arguments.length) return this._baseApiUrl;
this._baseApiUrl = _baseApiUrl;
return this;
}
}, {
key: "_initViews",
value: function _initViews() {
this._views = {
"DashboardView": new _ViewDashboardView2["default"]().setEntity(this),
"MenuView": new _ViewMenuView2["default"]().setEntity(this),
"ListView": new _ViewListView2["default"]().setEntity(this),
"CreateView": new _ViewCreateView2["default"]().setEntity(this),
"EditView": new _ViewEditView2["default"]().setEntity(this),
"DeleteView": new _ViewDeleteView2["default"]().setEntity(this),
"BatchDeleteView": new _ViewBatchDeleteView2["default"]().setEntity(this),
"ExportView": new _ViewExportView2["default"]().setEntity(this),
"ShowView": new _ViewShowView2["default"]().setEntity(this)
};
}
}, {
key: "identifier",
value: function identifier(value) {
if (!arguments.length) return this._identifierField;
if (!(value instanceof _FieldField2["default"])) {
throw new Error("Entity " + this.name() + ": identifier must be an instance of Field.");
}
this._identifierField = value;
return this;
}
}, {
key: "readOnly",
value: function readOnly() {
this._isReadOnly = true;
createMethod(createMethod) {
if (!arguments.length) return this._createMethod;
this._createMethod = createMethod;
return this;
}
this._views["CreateView"].disable();
this._views["EditView"].disable();
this._views["DeleteView"].disable();
this._views["BatchDeleteView"].disable();
updateMethod(updateMethod) {
if (!arguments.length) return this._updateMethod;
this._updateMethod = updateMethod;
return this;
}
return this;
}
}, {
key: "getErrorMessage",
value: function getErrorMessage(response) {
if (typeof this._errorMessage === "function") {
return this._errorMessage(response);
}
retrieveMethod(retrieveMethod) {
if (!arguments.length) return this._retrieveMethod;
this._retrieveMethod = retrieveMethod;
return this;
}
return this._errorMessage;
}
}, {
key: "errorMessage",
value: function errorMessage(_errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = _errorMessage;
return this;
}
}, {
key: "order",
value: function order(_order) {
if (!arguments.length) return this._order;
this._order = _order;
return this;
}
}, {
key: "url",
value: function url(_url) {
if (!arguments.length) return this._url;
this._url = _url;
return this;
}
}, {
key: "getUrl",
value: function getUrl(viewType, identifierValue, identifierName) {
if (typeof this._url === "function") {
return this._url(this.name(), viewType, identifierValue, identifierName);
}
deleteMethod(deleteMethod) {
if (!arguments.length) return this._deleteMethod;
this._deleteMethod = deleteMethod;
return this;
}
}
return this._url;
}
}, {
key: "createMethod",
value: function createMethod(_createMethod) {
if (!arguments.length) return this._createMethod;
this._createMethod = _createMethod;
return this;
}
}, {
key: "updateMethod",
value: function updateMethod(_updateMethod) {
if (!arguments.length) return this._updateMethod;
this._updateMethod = _updateMethod;
return this;
}
}, {
key: "retrieveMethod",
value: function retrieveMethod(_retrieveMethod) {
if (!arguments.length) return this._retrieveMethod;
this._retrieveMethod = _retrieveMethod;
return this;
}
}, {
key: "deleteMethod",
value: function deleteMethod(_deleteMethod) {
if (!arguments.length) return this._deleteMethod;
this._deleteMethod = _deleteMethod;
return this;
}
}, {
key: "uniqueId",
get: function () {
return this._uniqueId;
}
}, {
key: "views",
get: function () {
return this._views;
}
}, {
key: "isReadOnly",
get: function () {
return this._isReadOnly;
}
}]);
export default Entity;
return Entity;
})();
exports["default"] = Entity;
module.exports = exports["default"];
//# sourceMappingURL=Entity.js.map

@@ -1,6 +0,17 @@

import {clone, cloneAndFlatten, cloneAndNest} from './Utils/objectProperties';
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
class Entry {
constructor(entityName, values, identifierValue) {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _UtilsObjectProperties = require('./Utils/objectProperties');
var Entry = (function () {
function Entry(entityName, values, identifierValue) {
_classCallCheck(this, Entry);
this._entityName = entityName;

@@ -12,69 +23,92 @@ this.values = values || {};

get entityName() {
return this._entityName;
}
_createClass(Entry, [{
key: 'transformToRest',
get identifierValue() {
return this._identifierValue;
}
/**
* Transform an Entry to a JS object for the REST API Request
*
* @return {Object}
*/
value: function transformToRest(fields) {
static createForFields(fields, entityName) {
let entry = new Entry(entityName);
fields.forEach(field => {
entry.values[field.name()] = field.defaultValue();
});
return entry;
var restEntry = (0, _UtilsObjectProperties.clone)(this.values);
fields.forEach(function (field) {
var fieldName = field.name();
if (fieldName in restEntry) {
restEntry[fieldName] = field.getTransformedValue(restEntry[fieldName], restEntry);
}
});
}
/**
* Map a JS object from the REST API Response to an Entry
*
* @return {Entry}
*/
static createFromRest(restEntry, fields = [], entityName = '', identifierName = 'id') {
if (!restEntry || Object.keys(restEntry).length == 0) {
return Entry.createForFields(fields, entityName);
return (0, _UtilsObjectProperties.cloneAndNest)(restEntry);
}
const excludedFields = fields.filter(f => !f.flattenable()).map(f => f.name());
}, {
key: 'entityName',
get: function () {
return this._entityName;
}
}, {
key: 'identifierValue',
get: function () {
return this._identifierValue;
}
}], [{
key: 'createForFields',
value: function createForFields(fields, entityName) {
var entry = new Entry(entityName);
fields.forEach(function (field) {
entry.values[field.name()] = field.defaultValue();
});
return entry;
}
}, {
key: 'createFromRest',
let values = cloneAndFlatten(restEntry, excludedFields);
/**
* Map a JS object from the REST API Response to an Entry
*
* @return {Entry}
*/
value: function createFromRest(restEntry) {
var fields = arguments[1] === undefined ? [] : arguments[1];
var entityName = arguments[2] === undefined ? '' : arguments[2];
var identifierName = arguments[3] === undefined ? 'id' : arguments[3];
fields.forEach(field => {
let fieldName = field.name();
values[fieldName] = field.getMappedValue(values[fieldName], values);
});
if (!restEntry || Object.keys(restEntry).length == 0) {
return Entry.createForFields(fields, entityName);
}
var excludedFields = fields.filter(function (f) {
return !f.flattenable();
}).map(function (f) {
return f.name();
});
return new Entry(entityName, values, values[identifierName]);
}
var values = (0, _UtilsObjectProperties.cloneAndFlatten)(restEntry, excludedFields);
/**
* Map an array of JS objects from the REST API Response to an array of Entries
*
* @return {Array[Entry]}
*/
static createArrayFromRest(restEntries, fields, entityName, identifierName) {
return restEntries.map(e => Entry.createFromRest(e, fields, entityName, identifierName));
}
fields.forEach(function (field) {
var fieldName = field.name();
values[fieldName] = field.getMappedValue(values[fieldName], values);
});
/**
* Transform an Entry to a JS object for the REST API Request
*
* @return {Object}
*/
transformToRest(fields) {
return new Entry(entityName, values, values[identifierName]);
}
}, {
key: 'createArrayFromRest',
let restEntry = clone(this.values);
fields.forEach(field => {
let fieldName = field.name();
if (fieldName in restEntry) {
restEntry[fieldName] = field.getTransformedValue(restEntry[fieldName], restEntry)
}
});
/**
* Map an array of JS objects from the REST API Response to an array of Entries
*
* @return {Array[Entry]}
*/
value: function createArrayFromRest(restEntries, fields, entityName, identifierName) {
return restEntries.map(function (e) {
return Entry.createFromRest(e, fields, entityName, identifierName);
});
}
}]);
return cloneAndNest(restEntry);
}
return Entry;
})();
}
export default Entry;
exports['default'] = Entry;
module.exports = exports['default'];
//# sourceMappingURL=Entry.js.map

@@ -1,129 +0,246 @@

import Application from "./Application";
import Entity from "./Entity/Entity";
import DataStore from "./DataStore/DataStore";
import PromisesResolver from "./Utils/PromisesResolver";
"use strict";
import ReadQueries from "./Queries/ReadQueries";
import WriteQueries from "./Queries/WriteQueries";
Object.defineProperty(exports, "__esModule", {
value: true
});
import Field from "./Field/Field";
import BooleanField from "./Field/BooleanField";
import ChoiceField from "./Field/ChoiceField";
import ChoicesField from "./Field/ChoicesField";
import DateField from "./Field/DateField";
import DateTimeField from "./Field/DateTimeField";
import EmailField from "./Field/EmailField";
import EmbeddedListField from "./Field/EmbeddedListField";
import FloatField from "./Field/FloatField.js";
import FileField from "./Field/FileField";
import JsonField from "./Field/JsonField";
import NumberField from "./Field/NumberField";
import PasswordField from "./Field/PasswordField";
import ReferenceField from "./Field/ReferenceField";
import ReferencedListField from "./Field/ReferencedListField";
import ReferenceManyField from "./Field/ReferenceManyField";
import TemplateField from "./Field/TemplateField";
import TextField from "./Field/TextField";
import WysiwygField from "./Field/WysiwygField";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
import Menu from './Menu/Menu';
import Collection from './Collection';
import Dashboard from './Dashboard';
import Entry from './Entry';
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
class Factory {
constructor() {
this._fieldTypes = [];
this._init();
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
application(name, debug) {
return new Application(name, debug);
}
var _Application = require("./Application");
entity(name) {
return new Entity(name);
}
var _Application2 = _interopRequireDefault(_Application);
field(name, type) {
type = type || 'string';
var _EntityEntity = require("./Entity/Entity");
if (!(type in this._fieldTypes)) {
throw new Error(`Unknown field type "${type}".`);
}
var _EntityEntity2 = _interopRequireDefault(_EntityEntity);
return new this._fieldTypes[type](name);
}
var _DataStoreDataStore = require("./DataStore/DataStore");
registerFieldType(name, constructor) {
this._fieldTypes[name] = constructor;
}
var _DataStoreDataStore2 = _interopRequireDefault(_DataStoreDataStore);
getFieldConstructor(name) {
return this._fieldTypes[name];
}
var _UtilsPromisesResolver = require("./Utils/PromisesResolver");
menu(entity) {
let menu = new Menu();
if (entity) {
menu.populateFromEntity(entity);
}
return menu;
}
var _UtilsPromisesResolver2 = _interopRequireDefault(_UtilsPromisesResolver);
dashboard() {
return new Dashboard();
}
var _QueriesReadQueries = require("./Queries/ReadQueries");
collection(entity) {
let collection = new Collection();
if (entity) {
collection.setEntity(entity);
}
return collection;
}
var _QueriesReadQueries2 = _interopRequireDefault(_QueriesReadQueries);
getEntryConstructor() {
return Entry;
}
var _QueriesWriteQueries = require("./Queries/WriteQueries");
getDataStore() {
return new DataStore();
}
var _QueriesWriteQueries2 = _interopRequireDefault(_QueriesWriteQueries);
getReadQueries(RestWrapper, PromisesResolver, Application) {
return new ReadQueries(RestWrapper, PromisesResolver, Application);
}
var _FieldField = require("./Field/Field");
getWriteQueries(RestWrapper, PromisesResolver, Application) {
return new WriteQueries(RestWrapper, PromisesResolver, Application);
}
var _FieldField2 = _interopRequireDefault(_FieldField);
getPromisesResolver() {
return PromisesResolver;
}
var _FieldBooleanField = require("./Field/BooleanField");
_init() {
this.registerFieldType('boolean', BooleanField);
this.registerFieldType('choice', ChoiceField);
this.registerFieldType('choices', ChoicesField);
this.registerFieldType('date', DateField);
this.registerFieldType('datetime', DateTimeField);
this.registerFieldType('email', EmailField);
this.registerFieldType('embedded_list', EmbeddedListField);
this.registerFieldType('float', FloatField);
this.registerFieldType('string', Field);
this.registerFieldType('file', FileField);
this.registerFieldType('json', JsonField);
this.registerFieldType('number', NumberField);
this.registerFieldType('password', PasswordField);
this.registerFieldType('reference', ReferenceField);
this.registerFieldType('reference_many', ReferenceManyField);
this.registerFieldType('referenced_list', ReferencedListField);
this.registerFieldType('template', TemplateField);
this.registerFieldType('text', TextField);
this.registerFieldType('wysiwyg', WysiwygField);
var _FieldBooleanField2 = _interopRequireDefault(_FieldBooleanField);
var _FieldChoiceField = require("./Field/ChoiceField");
var _FieldChoiceField2 = _interopRequireDefault(_FieldChoiceField);
var _FieldChoicesField = require("./Field/ChoicesField");
var _FieldChoicesField2 = _interopRequireDefault(_FieldChoicesField);
var _FieldDateField = require("./Field/DateField");
var _FieldDateField2 = _interopRequireDefault(_FieldDateField);
var _FieldDateTimeField = require("./Field/DateTimeField");
var _FieldDateTimeField2 = _interopRequireDefault(_FieldDateTimeField);
var _FieldEmailField = require("./Field/EmailField");
var _FieldEmailField2 = _interopRequireDefault(_FieldEmailField);
var _FieldEmbeddedListField = require("./Field/EmbeddedListField");
var _FieldEmbeddedListField2 = _interopRequireDefault(_FieldEmbeddedListField);
var _FieldFloatFieldJs = require("./Field/FloatField.js");
var _FieldFloatFieldJs2 = _interopRequireDefault(_FieldFloatFieldJs);
var _FieldFileField = require("./Field/FileField");
var _FieldFileField2 = _interopRequireDefault(_FieldFileField);
var _FieldJsonField = require("./Field/JsonField");
var _FieldJsonField2 = _interopRequireDefault(_FieldJsonField);
var _FieldNumberField = require("./Field/NumberField");
var _FieldNumberField2 = _interopRequireDefault(_FieldNumberField);
var _FieldPasswordField = require("./Field/PasswordField");
var _FieldPasswordField2 = _interopRequireDefault(_FieldPasswordField);
var _FieldReferenceField = require("./Field/ReferenceField");
var _FieldReferenceField2 = _interopRequireDefault(_FieldReferenceField);
var _FieldReferencedListField = require("./Field/ReferencedListField");
var _FieldReferencedListField2 = _interopRequireDefault(_FieldReferencedListField);
var _FieldReferenceManyField = require("./Field/ReferenceManyField");
var _FieldReferenceManyField2 = _interopRequireDefault(_FieldReferenceManyField);
var _FieldTemplateField = require("./Field/TemplateField");
var _FieldTemplateField2 = _interopRequireDefault(_FieldTemplateField);
var _FieldTextField = require("./Field/TextField");
var _FieldTextField2 = _interopRequireDefault(_FieldTextField);
var _FieldWysiwygField = require("./Field/WysiwygField");
var _FieldWysiwygField2 = _interopRequireDefault(_FieldWysiwygField);
var _MenuMenu = require("./Menu/Menu");
var _MenuMenu2 = _interopRequireDefault(_MenuMenu);
var _Collection = require("./Collection");
var _Collection2 = _interopRequireDefault(_Collection);
var _Dashboard = require("./Dashboard");
var _Dashboard2 = _interopRequireDefault(_Dashboard);
var _Entry = require("./Entry");
var _Entry2 = _interopRequireDefault(_Entry);
var Factory = (function () {
function Factory() {
_classCallCheck(this, Factory);
this._fieldTypes = [];
this._init();
}
}
export default Factory;
_createClass(Factory, [{
key: "application",
value: function application(name, debug) {
return new _Application2["default"](name, debug);
}
}, {
key: "entity",
value: function entity(name) {
return new _EntityEntity2["default"](name);
}
}, {
key: "field",
value: function field(name, type) {
type = type || "string";
if (!(type in this._fieldTypes)) {
throw new Error("Unknown field type \"" + type + "\".");
}
return new this._fieldTypes[type](name);
}
}, {
key: "registerFieldType",
value: function registerFieldType(name, constructor) {
this._fieldTypes[name] = constructor;
}
}, {
key: "getFieldConstructor",
value: function getFieldConstructor(name) {
return this._fieldTypes[name];
}
}, {
key: "menu",
value: function menu(entity) {
var menu = new _MenuMenu2["default"]();
if (entity) {
menu.populateFromEntity(entity);
}
return menu;
}
}, {
key: "dashboard",
value: function dashboard() {
return new _Dashboard2["default"]();
}
}, {
key: "collection",
value: function collection(entity) {
var collection = new _Collection2["default"]();
if (entity) {
collection.setEntity(entity);
}
return collection;
}
}, {
key: "getEntryConstructor",
value: function getEntryConstructor() {
return _Entry2["default"];
}
}, {
key: "getDataStore",
value: function getDataStore() {
return new _DataStoreDataStore2["default"]();
}
}, {
key: "getReadQueries",
value: function getReadQueries(RestWrapper, PromisesResolver, Application) {
return new _QueriesReadQueries2["default"](RestWrapper, PromisesResolver, Application);
}
}, {
key: "getWriteQueries",
value: function getWriteQueries(RestWrapper, PromisesResolver, Application) {
return new _QueriesWriteQueries2["default"](RestWrapper, PromisesResolver, Application);
}
}, {
key: "getPromisesResolver",
value: function getPromisesResolver() {
return _UtilsPromisesResolver2["default"];
}
}, {
key: "_init",
value: function _init() {
this.registerFieldType("boolean", _FieldBooleanField2["default"]);
this.registerFieldType("choice", _FieldChoiceField2["default"]);
this.registerFieldType("choices", _FieldChoicesField2["default"]);
this.registerFieldType("date", _FieldDateField2["default"]);
this.registerFieldType("datetime", _FieldDateTimeField2["default"]);
this.registerFieldType("email", _FieldEmailField2["default"]);
this.registerFieldType("embedded_list", _FieldEmbeddedListField2["default"]);
this.registerFieldType("float", _FieldFloatFieldJs2["default"]);
this.registerFieldType("string", _FieldField2["default"]);
this.registerFieldType("file", _FieldFileField2["default"]);
this.registerFieldType("json", _FieldJsonField2["default"]);
this.registerFieldType("number", _FieldNumberField2["default"]);
this.registerFieldType("password", _FieldPasswordField2["default"]);
this.registerFieldType("reference", _FieldReferenceField2["default"]);
this.registerFieldType("reference_many", _FieldReferenceManyField2["default"]);
this.registerFieldType("referenced_list", _FieldReferencedListField2["default"]);
this.registerFieldType("template", _FieldTemplateField2["default"]);
this.registerFieldType("text", _FieldTextField2["default"]);
this.registerFieldType("wysiwyg", _FieldWysiwygField2["default"]);
}
}]);
return Factory;
})();
exports["default"] = Factory;
module.exports = exports["default"];
//# sourceMappingURL=Factory.js.map

@@ -1,26 +0,48 @@

import ChoiceField from "./ChoiceField";
"use strict";
class BooleanField extends ChoiceField {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ChoiceField2 = require("./ChoiceField");
var _ChoiceField3 = _interopRequireDefault(_ChoiceField2);
var BooleanField = (function (_ChoiceField) {
function BooleanField(name) {
_classCallCheck(this, BooleanField);
_get(Object.getPrototypeOf(BooleanField.prototype), "constructor", this).call(this, name);
this._type = "boolean";
this._choices = [
{ value: null, label: 'undefined' },
{ value: true, label: 'true' },
{ value: false, label: 'false' }
];
this._filterChoices = [
{ value: true, label: 'true' },
{ value: false, label: 'false' }
];
this._choices = [{ value: null, label: "undefined" }, { value: true, label: "true" }, { value: false, label: "false" }];
this._filterChoices = [{ value: true, label: "true" }, { value: false, label: "false" }];
}
filterChoices(filterChoices) {
if (!arguments.length) return this._filterChoices;
this._filterChoices = filterChoices;
_inherits(BooleanField, _ChoiceField);
return this;
}
}
_createClass(BooleanField, [{
key: "filterChoices",
value: function filterChoices(_filterChoices) {
if (!arguments.length) return this._filterChoices;
this._filterChoices = _filterChoices;
export default BooleanField;
return this;
}
}]);
return BooleanField;
})(_ChoiceField3["default"]);
exports["default"] = BooleanField;
module.exports = exports["default"];
//# sourceMappingURL=BooleanField.js.map

@@ -1,6 +0,26 @@

import Field from "./Field";
"use strict";
class ChoiceField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var ChoiceField = (function (_Field) {
function ChoiceField(name) {
_classCallCheck(this, ChoiceField);
_get(Object.getPrototypeOf(ChoiceField.prototype), "constructor", this).call(this, name);
this._type = "choice";

@@ -10,16 +30,28 @@ this._choices = [];

choices(choices) {
if (!arguments.length) return this._choices;
this._choices = choices;
return this;
}
_inherits(ChoiceField, _Field);
getLabelForChoice(value, entry) {
let choices = typeof(this._choices) === 'function' ? this._choices(entry) : this._choices;
let choice = choices.filter(c => c.value == value).pop();
return choice ? choice.label : null;
}
}
_createClass(ChoiceField, [{
key: "choices",
value: function choices(_choices) {
if (!arguments.length) return this._choices;
this._choices = _choices;
export default ChoiceField;
return this;
}
}, {
key: "getLabelForChoice",
value: function getLabelForChoice(value, entry) {
var choices = typeof this._choices === "function" ? this._choices(entry) : this._choices;
var choice = choices.filter(function (c) {
return c.value == value;
}).pop();
return choice ? choice.label : null;
}
}]);
return ChoiceField;
})(_Field3["default"]);
exports["default"] = ChoiceField;
module.exports = exports["default"];
//# sourceMappingURL=ChoiceField.js.map

@@ -1,10 +0,34 @@

import ChoiceField from "./ChoiceField";
"use strict";
class ChoicesField extends ChoiceField {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ChoiceField2 = require("./ChoiceField");
var _ChoiceField3 = _interopRequireDefault(_ChoiceField2);
var ChoicesField = (function (_ChoiceField) {
function ChoicesField(name) {
_classCallCheck(this, ChoicesField);
_get(Object.getPrototypeOf(ChoicesField.prototype), "constructor", this).call(this, name);
this._type = "choices";
}
}
export default ChoicesField;
_inherits(ChoicesField, _ChoiceField);
return ChoicesField;
})(_ChoiceField3["default"]);
exports["default"] = ChoicesField;
module.exports = exports["default"];
//# sourceMappingURL=ChoicesField.js.map

@@ -1,9 +0,29 @@

import Field from "./Field";
"use strict";
class DateField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var DateField = (function (_Field) {
function DateField(name) {
_classCallCheck(this, DateField);
_get(Object.getPrototypeOf(DateField.prototype), "constructor", this).call(this, name);
this._format = null;
this._parse = function(date) {
this._parse = function (date) {
if (date instanceof Date) {

@@ -15,4 +35,4 @@ // the datepicker returns a JS Date object, with hours, minutes and timezone

let dateString = date.toJSON();
return dateString ? dateString.substr(0,10) : null;
var dateString = date.toJSON();
return dateString ? dateString.substr(0, 10) : null;
}

@@ -24,15 +44,25 @@ return date;

format(value) {
if (!arguments.length) return this._format;
this._format = value;
return this;
}
_inherits(DateField, _Field);
parse(value) {
if (!arguments.length) return this._parse;
this._parse = value;
return this;
}
}
_createClass(DateField, [{
key: "format",
value: function format(value) {
if (!arguments.length) return this._format;
this._format = value;
return this;
}
}, {
key: "parse",
value: function parse(value) {
if (!arguments.length) return this._parse;
this._parse = value;
return this;
}
}]);
export default DateField;
return DateField;
})(_Field3["default"]);
exports["default"] = DateField;
module.exports = exports["default"];
//# sourceMappingURL=DateField.js.map

@@ -1,16 +0,40 @@

import DateField from "./DateField";
"use strict";
class DateTimeField extends DateField {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _DateField2 = require("./DateField");
var _DateField3 = _interopRequireDefault(_DateField2);
var DateTimeField = (function (_DateField) {
function DateTimeField(name) {
_classCallCheck(this, DateTimeField);
_get(Object.getPrototypeOf(DateTimeField.prototype), "constructor", this).call(this, name);
this._format = null;
this._parse = function(date) {
this._parse = function (date) {
return date;
};
this._type = 'datetime';
this._type = "datetime";
}
}
export default DateTimeField;
_inherits(DateTimeField, _DateField);
return DateTimeField;
})(_DateField3["default"]);
exports["default"] = DateTimeField;
module.exports = exports["default"];
//# sourceMappingURL=DateTimeField.js.map

@@ -1,10 +0,34 @@

import Field from "./Field";
"use strict";
class EmailField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var EmailField = (function (_Field) {
function EmailField(name) {
_classCallCheck(this, EmailField);
_get(Object.getPrototypeOf(EmailField.prototype), "constructor", this).call(this, name);
this._type = "email";
}
}
export default EmailField;
_inherits(EmailField, _Field);
return EmailField;
})(_Field3["default"]);
exports["default"] = EmailField;
module.exports = exports["default"];
//# sourceMappingURL=EmailField.js.map

@@ -1,4 +0,25 @@

import Field from "./Field";
import Entity from "../Entity/Entity";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var _EntityEntity = require("../Entity/Entity");
var _EntityEntity2 = _interopRequireDefault(_EntityEntity);
/**

@@ -25,8 +46,11 @@ * Map an embedded list in the entry

*/
class EmbeddedListField extends Field {
constructor(name) {
super(name);
this._type = 'embedded_list';
var EmbeddedListField = (function (_Field) {
function EmbeddedListField(name) {
_classCallCheck(this, EmbeddedListField);
_get(Object.getPrototypeOf(EmbeddedListField.prototype), "constructor", this).call(this, name);
this._type = "embedded_list";
this._flattenable = false;
this._targetEntity = new Entity(); // link to an empty entity by default
this._targetEntity = new _EntityEntity2["default"](); // link to an empty entity by default
this._targetFields = [];

@@ -39,93 +63,112 @@ this._sortField = null;

/**
* Optionally set the target Entity
*
* Useful if the embedded entries can be edited in standalone
*/
targetEntity(entity) {
if (!arguments.length) {
return this._targetEntity;
}
this._targetEntity = entity;
_inherits(EmbeddedListField, _Field);
return this;
}
_createClass(EmbeddedListField, [{
key: "targetEntity",
/**
* List the fields to map in the embedded entries
*
* @example
*
* embeddedListField.targetFields([
* new DateField('date'),
* new StringField('author'),
* new StringField('body')
* ])
*/
targetFields(value) {
if (!arguments.length) return this._targetFields;
this._targetFields = value;
/**
* Optionally set the target Entity
*
* Useful if the embedded entries can be edited in standalone
*/
value: function targetEntity(entity) {
if (!arguments.length) {
return this._targetEntity;
}
this._targetEntity = entity;
return this;
}
/**
* Name of the field used for sorting.
*
* @param string
*/
sortField() {
if (arguments.length) {
this._sortField = arguments[0];
return this;
}
}, {
key: "targetFields",
return this._sortField ? this._sortField : this.targetEntity().identifier().name();
}
/**
* List the fields to map in the embedded entries
*
* @example
*
* embeddedListField.targetFields([
* new DateField('date'),
* new StringField('author'),
* new StringField('body')
* ])
*/
value: function targetFields(value) {
if (!arguments.length) return this._targetFields;
this._targetFields = value;
/**
* Direction used for sorting.
*
* @param String either 'ASC' or 'DESC'
*/
sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
}
}, {
key: "sortField",
return this._sortDir;
}
/**
* Name of the field used for sorting.
*
* @param string
*/
value: function sortField() {
if (arguments.length) {
this._sortField = arguments[0];
return this;
}
listActions(actions) {
if (!arguments.length) {
return this._listActions;
return this._sortField ? this._sortField : this.targetEntity().identifier().name();
}
}, {
key: "sortDir",
this._listActions = actions;
/**
* Direction used for sorting.
*
* @param String either 'ASC' or 'DESC'
*/
value: function sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
}
return this;
}
return this._sortDir;
}
}, {
key: "listActions",
value: function listActions(actions) {
if (!arguments.length) {
return this._listActions;
}
/**
* Define permanent filters to be added to the REST API calls
*
* nga.field('post_id', 'reference').permanentFilters({
* published: true
* });
* // related API call will be /posts/:id?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
this._listActions = actions;
return this;
}
}, {
key: "permanentFilters",
this._permanentFilters = filters;
/**
* Define permanent filters to be added to the REST API calls
*
* nga.field('post_id', 'reference').permanentFilters({
* published: true
* });
* // related API call will be /posts/:id?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
value: function permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
}
return this;
}
}
this._permanentFilters = filters;
export default EmbeddedListField;
return this;
}
}]);
return EmbeddedListField;
})(_Field3["default"]);
exports["default"] = EmbeddedListField;
module.exports = exports["default"];
//# sourceMappingURL=EmbeddedListField.js.map

@@ -1,7 +0,23 @@

import stringUtils from "../Utils/stringUtils";
"use strict";
class Field {
constructor(name) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _UtilsStringUtils = require("../Utils/stringUtils");
var _UtilsStringUtils2 = _interopRequireDefault(_UtilsStringUtils);
var Field = (function () {
function Field(name) {
_classCallCheck(this, Field);
this._name = name || Math.random().toString(36).substring(7);
this._detailLink = (name === 'id');
this._detailLink = name === "id";
this._type = "string";

@@ -14,7 +30,7 @@ this._order = null;

this._cssClasses = null;
this._validation = { required: false, minlength : 0, maxlength : 99999 };
this._validation = { required: false, minlength: 0, maxlength: 99999 };
this._defaultValue = null;
this._editable = true;
this._sortable = true;
this._detailLinkRoute = 'edit';
this._detailLinkRoute = "edit";
this._pinned = false;

@@ -24,224 +40,262 @@ this._flattenable = true;

this.list = true;
this._template = () => '';
this._template = function () {
return "";
};
this._templateIncludesLabel = false;
}
label() {
if (arguments.length) {
this._label = arguments[0];
return this;
_createClass(Field, [{
key: "label",
value: function label() {
if (arguments.length) {
this._label = arguments[0];
return this;
}
if (this._label === null) {
return _UtilsStringUtils2["default"].camelCase(this._name);
}
return this._label;
}
}, {
key: "type",
value: function type() {
return this._type;
}
}, {
key: "name",
value: function name() {
if (arguments.length) {
this._name = arguments[0];
return this;
}
if (this._label === null) {
return stringUtils.camelCase(this._name);
return this._name;
}
}, {
key: "order",
value: function order() {
if (arguments.length) {
if (arguments[1] !== true) {
console.warn("Setting order with Field.order is deprecated, order directly in fields array");
}
this._order = arguments[0];
return this;
}
return this._label;
}
return this._order;
}
}, {
key: "isDetailLink",
value: function isDetailLink(detailLink) {
if (arguments.length) {
this._detailLink = arguments[0];
return this;
}
type() {
return this._type;
}
if (this._detailLink === null) {
return this._name === "id";
}
name() {
if (arguments.length) {
this._name = arguments[0];
return this;
return this._detailLink;
}
}, {
key: "map",
return this._name;
}
order() {
if (arguments.length) {
if(arguments[1] !== true) {
console.warn('Setting order with Field.order is deprecated, order directly in fields array');
/**
* Add a function to be applied to the response object to turn it into an entry
*/
value: function map(fn) {
if (!fn) return this._maps;
if (typeof fn !== "function") {
var type = typeof fn;
throw new Error("Map argument should be a function, " + type + " given.");
}
this._order = arguments[0];
return this;
}
return this._order;
}
this._maps.push(fn);
isDetailLink(detailLink) {
if (arguments.length) {
this._detailLink = arguments[0];
return this;
}
}, {
key: "hasMaps",
value: function hasMaps() {
return !!this._maps.length;
}
}, {
key: "getMappedValue",
value: function getMappedValue(value, entry) {
for (var i in this._maps) {
value = this._maps[i](value, entry);
}
if (this._detailLink === null) {
return this._name === 'id';
return value;
}
}, {
key: "transform",
return this._detailLink;
}
/**
* Add a function to be applied to the entry to turn it into a response object
*/
value: function transform(fn) {
if (!fn) return this._transforms;
if (typeof fn !== "function") {
var type = typeof fn;
throw new Error("transform argument should be a function, " + type + " given.");
}
set detailLink(isDetailLink) {
return this._detailLink = isDetailLink;
}
this._transforms.push(fn);
/**
* Add a function to be applied to the response object to turn it into an entry
*/
map(fn) {
if (!fn) return this._maps;
if (typeof(fn) !== "function") {
let type = typeof(fn);
throw new Error(`Map argument should be a function, ${type} given.`);
return this;
}
}, {
key: "hasTranforms",
value: function hasTranforms() {
return !!this._transforms.length;
}
}, {
key: "getTransformedValue",
value: function getTransformedValue(value, entry) {
for (var i in this._transforms) {
value = this._transforms[i](value, entry);
}
this._maps.push(fn);
return this;
}
hasMaps() {
return !!this._maps.length;
}
getMappedValue(value, entry) {
for (let i in this._maps) {
value = this._maps[i](value, entry);
return value;
}
}, {
key: "attributes",
value: function attributes(_attributes) {
if (!arguments.length) {
return this._attributes;
}
return value;
}
this._attributes = _attributes;
/**
* Add a function to be applied to the entry to turn it into a response object
*/
transform(fn) {
if (!fn) return this._transforms;
if (typeof(fn) !== "function") {
let type = typeof(fn);
throw new Error(`transform argument should be a function, ${type} given.`);
return this;
}
}, {
key: "cssClasses",
value: function cssClasses(classes) {
if (!arguments.length) return this._cssClasses;
this._cssClasses = classes;
return this;
}
}, {
key: "getCssClasses",
value: function getCssClasses(entry) {
if (!this._cssClasses) {
return "";
}
this._transforms.push(fn);
if (this._cssClasses.constructor === Array) {
return this._cssClasses.join(" ");
}
return this;
}
if (typeof this._cssClasses === "function") {
return this._cssClasses(entry);
}
hasTranforms() {
return !!this._transforms.length;
}
getTransformedValue(value, entry) {
for (let i in this._transforms) {
value = this._transforms[i](value, entry);
return this._cssClasses;
}
}, {
key: "validation",
value: function validation(_validation) {
if (!arguments.length) {
return this._validation;
}
return value;
}
for (var property in _validation) {
if (!_validation.hasOwnProperty(property)) continue;
if (_validation[property] === null) {
delete this._validation[property];
} else {
this._validation[property] = _validation[property];
}
}
attributes(attributes) {
if (!arguments.length) {
return this._attributes;
return this;
}
this._attributes = attributes;
return this;
}
cssClasses(classes) {
if (!arguments.length) return this._cssClasses;
this._cssClasses = classes;
return this;
}
getCssClasses(entry) {
if (!this._cssClasses) {
return '';
}, {
key: "defaultValue",
value: function defaultValue(_defaultValue) {
if (!arguments.length) return this._defaultValue;
this._defaultValue = _defaultValue;
return this;
}
if (this._cssClasses.constructor === Array) {
return this._cssClasses.join(' ');
}, {
key: "editable",
value: function editable(_editable) {
if (!arguments.length) return this._editable;
this._editable = _editable;
return this;
}
if (typeof(this._cssClasses) === 'function') {
return this._cssClasses(entry);
}, {
key: "sortable",
value: function sortable(_sortable) {
if (!arguments.length) return this._sortable;
this._sortable = _sortable;
return this;
}
return this._cssClasses;
}
validation(validation) {
if (!arguments.length) {
return this._validation;
}, {
key: "detailLinkRoute",
value: function detailLinkRoute(route) {
if (!arguments.length) return this._detailLinkRoute;
this._detailLinkRoute = route;
return this;
}
}, {
key: "pinned",
value: function pinned(_pinned) {
if (!arguments.length) return this._pinned;
this._pinned = _pinned;
return this;
}
}, {
key: "flattenable",
value: function flattenable() {
return this._flattenable;
}
}, {
key: "getTemplateValue",
value: function getTemplateValue(data) {
if (typeof this._template === "function") {
return this._template(data);
}
for (let property in validation) {
if (!validation.hasOwnProperty(property)) continue;
if (validation[property] === null) {
delete this._validation[property];
} else {
this._validation[property] = validation[property];
}
return this._template;
}
}, {
key: "getTemplateValueWithLabel",
value: function getTemplateValueWithLabel(data) {
return this._templateIncludesLabel ? this.getTemplateValue(data) : false;
}
}, {
key: "templateIncludesLabel",
value: function templateIncludesLabel(_templateIncludesLabel) {
if (!arguments.length) return this._templateIncludesLabel;
this._templateIncludesLabel = _templateIncludesLabel;
return this;
}
}, {
key: "template",
value: function template(_template) {
var templateIncludesLabel = arguments[1] === undefined ? false : arguments[1];
return this;
}
defaultValue(defaultValue) {
if (!arguments.length) return this._defaultValue;
this._defaultValue = defaultValue;
return this;
}
editable(editable) {
if (!arguments.length) return this._editable;
this._editable = editable;
return this;
}
sortable(sortable) {
if (!arguments.length) return this._sortable;
this._sortable = sortable;
return this;
}
detailLinkRoute(route) {
if (!arguments.length) return this._detailLinkRoute;
this._detailLinkRoute = route;
return this;
}
pinned(pinned) {
if (!arguments.length) return this._pinned;
this._pinned = pinned;
return this;
}
flattenable() {
return this._flattenable;
}
getTemplateValue(data) {
if (typeof(this._template) === 'function') {
return this._template(data);
if (!arguments.length) return this._template;
this._template = _template;
this._templateIncludesLabel = templateIncludesLabel;
return this;
}
}, {
key: "detailLink",
set: function (isDetailLink) {
return this._detailLink = isDetailLink;
}
}]);
return this._template;
}
return Field;
})();
getTemplateValueWithLabel(data) {
return this._templateIncludesLabel ? this.getTemplateValue(data) : false;
}
templateIncludesLabel(templateIncludesLabel) {
if (!arguments.length) return this._templateIncludesLabel;
this._templateIncludesLabel = templateIncludesLabel;
return this;
}
template(template, templateIncludesLabel = false) {
if (!arguments.length) return this._template;
this._template = template;
this._templateIncludesLabel = templateIncludesLabel;
return this;
}
}
export default Field;
exports["default"] = Field;
module.exports = exports["default"];
//# sourceMappingURL=Field.js.map

@@ -1,20 +0,49 @@

import Field from "./Field";
"use strict";
class FileField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var FileField = (function (_Field) {
function FileField(name) {
_classCallCheck(this, FileField);
_get(Object.getPrototypeOf(FileField.prototype), "constructor", this).call(this, name);
this._type = "file";
this._uploadInformation = {
url: '/upload',
accept: '*'
url: "/upload",
accept: "*"
};
}
uploadInformation(information) {
if (!arguments.length) return this._uploadInformation;
this._uploadInformation = information;
return this;
}
}
_inherits(FileField, _Field);
export default FileField;
_createClass(FileField, [{
key: "uploadInformation",
value: function uploadInformation(information) {
if (!arguments.length) return this._uploadInformation;
this._uploadInformation = information;
return this;
}
}]);
return FileField;
})(_Field3["default"]);
exports["default"] = FileField;
module.exports = exports["default"];
//# sourceMappingURL=FileField.js.map

@@ -1,11 +0,35 @@

import NumberField from "./NumberField";
'use strict';
class FloatField extends NumberField {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _NumberField2 = require('./NumberField');
var _NumberField3 = _interopRequireDefault(_NumberField2);
var FloatField = (function (_NumberField) {
function FloatField(name) {
_classCallCheck(this, FloatField);
_get(Object.getPrototypeOf(FloatField.prototype), 'constructor', this).call(this, name);
this._type = 'float';
this._format = '0.000';
}
}
export default FloatField;
_inherits(FloatField, _NumberField);
return FloatField;
})(_NumberField3['default']);
exports['default'] = FloatField;
module.exports = exports['default'];
//# sourceMappingURL=FloatField.js.map

@@ -1,11 +0,35 @@

import Field from "./Field";
"use strict";
class JsonField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var JsonField = (function (_Field) {
function JsonField(name) {
_classCallCheck(this, JsonField);
_get(Object.getPrototypeOf(JsonField.prototype), "constructor", this).call(this, name);
this._type = "json";
this._flattenable = false;
}
}
export default JsonField;
_inherits(JsonField, _Field);
return JsonField;
})(_Field3["default"]);
exports["default"] = JsonField;
module.exports = exports["default"];
//# sourceMappingURL=JsonField.js.map

@@ -1,6 +0,26 @@

import Field from "./Field";
"use strict";
class NumberField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var NumberField = (function (_Field) {
function NumberField(name) {
_classCallCheck(this, NumberField);
_get(Object.getPrototypeOf(NumberField.prototype), "constructor", this).call(this, name);
this._type = "number";

@@ -10,27 +30,37 @@ this._format = undefined;

/**
* Specify format pattern for number to string conversion.
*
* Based on NumeralJs, which uses a syntax similar to Excel.
*
* {@link} http://numeraljs.com/
* {@link} https://github.com/baumandm/angular-numeraljs
* {@example}
*
* nga.field('height', 'number').format('$0,0.00');
*/
format(value) {
if (!arguments.length) return this._format;
this._format = value;
return this;
}
_inherits(NumberField, _Field);
fractionSize(decimals) {
console.warn('NumberField.fractionSize() is deprecated, use NumberField.format() instead');
this.format('0.' + '0'.repeat(decimals));
return this;
}
_createClass(NumberField, [{
key: "format",
}
/**
* Specify format pattern for number to string conversion.
*
* Based on NumeralJs, which uses a syntax similar to Excel.
*
* {@link} http://numeraljs.com/
* {@link} https://github.com/baumandm/angular-numeraljs
* {@example}
*
* nga.field('height', 'number').format('$0,0.00');
*/
value: function format(value) {
if (!arguments.length) return this._format;
this._format = value;
return this;
}
}, {
key: "fractionSize",
value: function fractionSize(decimals) {
console.warn("NumberField.fractionSize() is deprecated, use NumberField.format() instead");
this.format("0." + "0".repeat(decimals));
return this;
}
}]);
export default NumberField;
return NumberField;
})(_Field3["default"]);
exports["default"] = NumberField;
module.exports = exports["default"];
//# sourceMappingURL=NumberField.js.map

@@ -1,10 +0,34 @@

import Field from "./Field";
"use strict";
class PasswordField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var PasswordField = (function (_Field) {
function PasswordField(name) {
_classCallCheck(this, PasswordField);
_get(Object.getPrototypeOf(PasswordField.prototype), "constructor", this).call(this, name);
this._type = "password";
}
}
export default PasswordField;
_inherits(PasswordField, _Field);
return PasswordField;
})(_Field3["default"]);
exports["default"] = PasswordField;
module.exports = exports["default"];
//# sourceMappingURL=PasswordField.js.map

@@ -1,7 +0,30 @@

import ReferenceField from "./ReferenceField";
import ReferenceExtractor from '../Utils/ReferenceExtractor';
'use strict';
class ReferencedListField extends ReferenceField {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ReferenceField2 = require('./ReferenceField');
var _ReferenceField3 = _interopRequireDefault(_ReferenceField2);
var _UtilsReferenceExtractor = require('../Utils/ReferenceExtractor');
var _UtilsReferenceExtractor2 = _interopRequireDefault(_UtilsReferenceExtractor);
var ReferencedListField = (function (_ReferenceField) {
function ReferencedListField(name) {
_classCallCheck(this, ReferencedListField);
_get(Object.getPrototypeOf(ReferencedListField.prototype), 'constructor', this).call(this, name);
this._type = 'referenced_list';

@@ -15,69 +38,86 @@ this._targetReferenceField = null;

targetReferenceField(value) {
if (!arguments.length) return this._targetReferenceField;
this._targetReferenceField = value;
return this;
}
_inherits(ReferencedListField, _ReferenceField);
targetFields(value) {
if (!arguments.length) return this._targetFields;
this._targetFields = value;
_createClass(ReferencedListField, [{
key: 'targetReferenceField',
value: function targetReferenceField(value) {
if (!arguments.length) return this._targetReferenceField;
this._targetReferenceField = value;
return this;
}
}, {
key: 'targetFields',
value: function targetFields(value) {
if (!arguments.length) return this._targetFields;
this._targetFields = value;
return this;
}
return this;
}
}, {
key: 'getGridColumns',
value: function getGridColumns() {
var columns = [];
for (var i = 0, l = this._targetFields.length; i < l; i++) {
var field = this._targetFields[i];
columns.push({
field: field,
label: field.label()
});
}
getGridColumns() {
let columns = [];
for (let i = 0, l = this._targetFields.length ; i < l ; i++) {
let field = this._targetFields[i];
columns.push({
field: field,
label: field.label()
});
return columns;
}
}, {
key: 'getSortFieldName',
value: function getSortFieldName() {
if (!this.sortField()) {
return null;
}
return columns;
}
getSortFieldName() {
if (!this.sortField()) {
return null;
return this._targetEntity.name() + '_ListView.' + this.sortField();
}
}, {
key: 'listActions',
value: function listActions(actions) {
if (!arguments.length) {
return this._listActions;
}
return this._targetEntity.name() + '_ListView.' + this.sortField();
}
this._listActions = actions;
listActions(actions) {
if (!arguments.length) {
return this._listActions;
return this;
}
}, {
key: 'entryCssClasses',
value: function entryCssClasses(classes) {
if (!arguments.length) {
return this._entryCssClasses;
}
this._listActions = actions;
this._entryCssClasses = classes;
return this;
}
entryCssClasses(classes) {
if (!arguments.length) {
return this._entryCssClasses;
return this;
}
}, {
key: 'getReferences',
value: function getReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getReferences(this._targetFields, withRemoteComplete);
}
}, {
key: 'getNonOptimizedReferences',
value: function getNonOptimizedReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getNonOptimizedReferences(this._targetFields, withRemoteComplete);
}
}, {
key: 'getOptimizedReferences',
value: function getOptimizedReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getOptimizedReferences(this._targetFields, withRemoteComplete);
}
}]);
this._entryCssClasses = classes;
return ReferencedListField;
})(_ReferenceField3['default']);
return this;
}
getReferences(withRemoteComplete) {
return ReferenceExtractor.getReferences(this._targetFields, withRemoteComplete);
}
getNonOptimizedReferences(withRemoteComplete) {
return ReferenceExtractor.getNonOptimizedReferences(this._targetFields, withRemoteComplete);
}
getOptimizedReferences(withRemoteComplete) {
return ReferenceExtractor.getOptimizedReferences(this._targetFields, withRemoteComplete);
}
}
export default ReferencedListField;
exports['default'] = ReferencedListField;
module.exports = exports['default'];
//# sourceMappingURL=ReferencedListField.js.map

@@ -1,6 +0,26 @@

import Field from "./Field";
'use strict';
class ReferenceField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require('./Field');
var _Field3 = _interopRequireDefault(_Field2);
var ReferenceField = (function (_Field) {
function ReferenceField(name) {
_classCallCheck(this, ReferenceField);
_get(Object.getPrototypeOf(ReferenceField.prototype), 'constructor', this).call(this, name);
this._type = 'reference';

@@ -16,3 +36,3 @@ this._targetEntity = null;

this._remoteComplete = false;
this._remoteCompleteOptions= {
this._remoteCompleteOptions = {
refreshDelay: 500

@@ -22,155 +42,181 @@ };

perPage(perPage) {
if (!arguments.length) return this._perPage;
this._perPage = perPage;
return this;
}
_inherits(ReferenceField, _Field);
datagridName() {
return this._targetEntity.name() + '_ListView';
}
targetEntity(entity) {
if (!arguments.length) {
return this._targetEntity;
_createClass(ReferenceField, [{
key: 'perPage',
value: function perPage(_perPage) {
if (!arguments.length) return this._perPage;
this._perPage = _perPage;
return this;
}
this._targetEntity = entity;
return this;
}
targetField(field) {
if (!arguments.length) return this._targetField;
this._targetField = field;
return this;
}
/**
* Define permanent filters to be added to the REST API calls
*
* nga.field('post_id', 'reference').permanentFilters({
* published: true
* });
* // related API call will be /posts/:id?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
}, {
key: 'datagridName',
value: function datagridName() {
return this._targetEntity.name() + '_ListView';
}
}, {
key: 'targetEntity',
value: function targetEntity(entity) {
if (!arguments.length) {
return this._targetEntity;
}
this._targetEntity = entity;
this._permanentFilters = filters;
return this;
}
/**
* @deprecated use permanentFilters() instead
*/
filters(filters) {
console.warn('ReferenceField.filters() is deprecated, please use ReferenceField.permanentFilters() instead');
return this.permanentFilters(filters);
}
sortField() {
if (arguments.length) {
this._sortField = arguments[0];
return this;
}
}, {
key: 'targetField',
value: function targetField(field) {
if (!arguments.length) return this._targetField;
this._targetField = field;
return this._sortField;
}
sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
}
}, {
key: 'permanentFilters',
return this._sortDir;
}
/**
* Define permanent filters to be added to the REST API calls
*
* nga.field('post_id', 'reference').permanentFilters({
* published: true
* });
* // related API call will be /posts/:id?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
value: function permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
}
singleApiCall(singleApiCall) {
if (!arguments.length) return this._singleApiCall;
this._singleApiCall = singleApiCall;
return this;
}
this._permanentFilters = filters;
hasSingleApiCall() {
return typeof this._singleApiCall === 'function';
}
return this;
}
}, {
key: 'filters',
getSingleApiCall(identifiers) {
return this.hasSingleApiCall() ? this._singleApiCall(identifiers) : this._singleApiCall;
}
/**
* @deprecated use permanentFilters() instead
*/
value: function filters(_filters) {
console.warn('ReferenceField.filters() is deprecated, please use ReferenceField.permanentFilters() instead');
return this.permanentFilters(_filters);
}
}, {
key: 'sortField',
value: function sortField() {
if (arguments.length) {
this._sortField = arguments[0];
return this;
}
getIdentifierValues(rawValues) {
let results = {};
let identifierName = this._name;
for (let i = 0, l = rawValues.length ; i < l ; i++) {
let identifier = rawValues[i][identifierName];
if (identifier == null) {
continue;
return this._sortField;
}
}, {
key: 'sortDir',
value: function sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
}
if (identifier instanceof Array) {
for (let j in identifier) {
results[identifier[j]] = true;
return this._sortDir;
}
}, {
key: 'singleApiCall',
value: function singleApiCall(_singleApiCall) {
if (!arguments.length) return this._singleApiCall;
this._singleApiCall = _singleApiCall;
return this;
}
}, {
key: 'hasSingleApiCall',
value: function hasSingleApiCall() {
return typeof this._singleApiCall === 'function';
}
}, {
key: 'getSingleApiCall',
value: function getSingleApiCall(identifiers) {
return this.hasSingleApiCall() ? this._singleApiCall(identifiers) : this._singleApiCall;
}
}, {
key: 'getIdentifierValues',
value: function getIdentifierValues(rawValues) {
var results = {};
var identifierName = this._name;
for (var i = 0, l = rawValues.length; i < l; i++) {
var identifier = rawValues[i][identifierName];
if (identifier == null) {
continue;
}
continue;
if (identifier instanceof Array) {
for (var j in identifier) {
results[identifier[j]] = true;
}
continue;
}
results[identifier] = true;
}
results[identifier] = true;
return Object.keys(results);
}
}, {
key: 'getSortFieldName',
value: function getSortFieldName() {
if (!this.sortField()) {
return null;
}
return Object.keys(results);
}
getSortFieldName() {
if (!this.sortField()) {
return null;
return this._targetEntity.name() + '_ListView.' + this.sortField();
}
}, {
key: 'remoteComplete',
return this._targetEntity.name() + '_ListView.' + this.sortField();
}
/**
* Enable autocompletion using REST API for choices.
*
* Available options are:
*
* * `refreshDelay`: minimal delay between two API calls in milliseconds. By default: 500.
* * `searchQuery`: a function returning the parameters to add to the query string basd on the input string.
*
* new ReferenceField('authors')
* .targetEntity(author)
* .targetField(new Field('name'))
* .remoteComplete(true, {
* refreshDelay: 300,
* // populate choices from the response of GET /tags?q=XXX
* searchQuery: function(search) { return { q: search }; }
* })
* .perPage(10) // limit the number of results to 10
*
* @param {Boolean} remoteComplete true to enable remote complete. False by default
* @param {Object} options Remote completion options (optional)
*/
remoteComplete(remoteComplete, options) {
if (!arguments.length) return this._remoteComplete;
this._remoteComplete = remoteComplete;
if (options) {
this.remoteCompleteOptions(options);
/**
* Enable autocompletion using REST API for choices.
*
* Available options are:
*
* * `refreshDelay`: minimal delay between two API calls in milliseconds. By default: 500.
* * `searchQuery`: a function returning the parameters to add to the query string basd on the input string.
*
* new ReferenceField('authors')
* .targetEntity(author)
* .targetField(new Field('name'))
* .remoteComplete(true, {
* refreshDelay: 300,
* // populate choices from the response of GET /tags?q=XXX
* searchQuery: function(search) { return { q: search }; }
* })
* .perPage(10) // limit the number of results to 10
*
* @param {Boolean} remoteComplete true to enable remote complete. False by default
* @param {Object} options Remote completion options (optional)
*/
value: function remoteComplete(_remoteComplete, options) {
if (!arguments.length) return this._remoteComplete;
this._remoteComplete = _remoteComplete;
if (options) {
this.remoteCompleteOptions(options);
}
return this;
}
return this;
}
}, {
key: 'remoteCompleteOptions',
value: function remoteCompleteOptions(options) {
if (!arguments.length) return this._remoteCompleteOptions;
this._remoteCompleteOptions = options;
return this;
}
}]);
remoteCompleteOptions(options) {
if (!arguments.length) return this._remoteCompleteOptions;
this._remoteCompleteOptions = options;
return this;
}
}
return ReferenceField;
})(_Field3['default']);
export default ReferenceField;
exports['default'] = ReferenceField;
module.exports = exports['default'];
//# sourceMappingURL=ReferenceField.js.map

@@ -1,10 +0,34 @@

import ReferenceField from "./ReferenceField";
"use strict";
class ReferenceManyField extends ReferenceField {
constructor(name) {
super(name);
this._type = 'reference_many';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ReferenceField2 = require("./ReferenceField");
var _ReferenceField3 = _interopRequireDefault(_ReferenceField2);
var ReferenceManyField = (function (_ReferenceField) {
function ReferenceManyField(name) {
_classCallCheck(this, ReferenceManyField);
_get(Object.getPrototypeOf(ReferenceManyField.prototype), "constructor", this).call(this, name);
this._type = "reference_many";
}
}
export default ReferenceManyField;
_inherits(ReferenceManyField, _ReferenceField);
return ReferenceManyField;
})(_ReferenceField3["default"]);
exports["default"] = ReferenceManyField;
module.exports = exports["default"];
//# sourceMappingURL=ReferenceManyField.js.map

@@ -1,11 +0,35 @@

import Field from "./Field";
"use strict";
class TemplateField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var TemplateField = (function (_Field) {
function TemplateField(name) {
_classCallCheck(this, TemplateField);
_get(Object.getPrototypeOf(TemplateField.prototype), "constructor", this).call(this, name);
this._type = "template";
this._flattenable = false;
}
}
export default TemplateField;
_inherits(TemplateField, _Field);
return TemplateField;
})(_Field3["default"]);
exports["default"] = TemplateField;
module.exports = exports["default"];
//# sourceMappingURL=TemplateField.js.map

@@ -1,10 +0,34 @@

import Field from "./Field";
"use strict";
class TextField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var TextField = (function (_Field) {
function TextField(name) {
_classCallCheck(this, TextField);
_get(Object.getPrototypeOf(TextField.prototype), "constructor", this).call(this, name);
this._type = "text";
}
}
export default TextField;
_inherits(TextField, _Field);
return TextField;
})(_Field3["default"]);
exports["default"] = TextField;
module.exports = exports["default"];
//# sourceMappingURL=TextField.js.map

@@ -1,6 +0,26 @@

import Field from "./Field";
"use strict";
class WysiwygField extends Field {
constructor(name) {
super(name);
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Field2 = require("./Field");
var _Field3 = _interopRequireDefault(_Field2);
var WysiwygField = (function (_Field) {
function WysiwygField(name) {
_classCallCheck(this, WysiwygField);
_get(Object.getPrototypeOf(WysiwygField.prototype), "constructor", this).call(this, name);
this._type = "wysiwyg";

@@ -11,15 +31,25 @@ this._stripTags = false;

stripTags(value) {
if (!arguments.length) return this._stripTags;
this._stripTags = value;
return this;
}
sanitize(value) {
if (!arguments.length) return this._sanitize;
this._sanitize = value;
return this;
}
}
_inherits(WysiwygField, _Field);
export default WysiwygField;
_createClass(WysiwygField, [{
key: "stripTags",
value: function stripTags(value) {
if (!arguments.length) return this._stripTags;
this._stripTags = value;
return this;
}
}, {
key: "sanitize",
value: function sanitize(value) {
if (!arguments.length) return this._sanitize;
this._sanitize = value;
return this;
}
}]);
return WysiwygField;
})(_Field3["default"]);
exports["default"] = WysiwygField;
module.exports = exports["default"];
//# sourceMappingURL=WysiwygField.js.map

@@ -1,3 +0,17 @@

import Entity from '../Entity/Entity'
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _EntityEntity = require('../Entity/Entity');
var _EntityEntity2 = _interopRequireDefault(_EntityEntity);
function alwaysFalse() {

@@ -8,6 +22,8 @@ return false;

var uuid = 0;
var autoClose = true;
var _autoClose = true;
class Menu {
constructor() {
var Menu = (function () {
function Menu() {
_classCallCheck(this, Menu);
this._link = null;

@@ -23,102 +39,132 @@ this._activeFunc = alwaysFalse;

title() {
if (arguments.length) {
this._title = arguments[0];
return this;
_createClass(Menu, [{
key: 'title',
value: function title() {
if (arguments.length) {
this._title = arguments[0];
return this;
}
return this._title;
}
return this._title;
}
}, {
key: 'isLink',
value: function isLink() {
return !!this._link;
}
}, {
key: 'link',
value: function link() {
var _this = this;
isLink() {
return !!this._link;
}
link() {
if (arguments.length) {
this._link = arguments[0];
if (this._activeFunc == alwaysFalse) {
this._activeFunc = url => url.indexOf(this._link) === 0;
if (arguments.length) {
this._link = arguments[0];
if (this._activeFunc == alwaysFalse) {
this._activeFunc = function (url) {
return url.indexOf(_this._link) === 0;
};
}
return this;
}
return this;
return this._link;
}
return this._link;
}
autoClose() {
if (arguments.length) {
autoClose = arguments[0];
return this;
}, {
key: 'autoClose',
value: function autoClose() {
if (arguments.length) {
_autoClose = arguments[0];
return this;
}
return _autoClose;
}
return autoClose;
}
active(activeFunc) {
if (arguments.length) {
this._activeFunc = arguments[0];
return this;
}, {
key: 'active',
value: function active(activeFunc) {
if (arguments.length) {
this._activeFunc = arguments[0];
return this;
}
return this._activeFunc;
}
return this._activeFunc;
}
isActive(url) {
return this._activeFunc(url);
}
isChildActive(url) {
return this.isActive(url) || (this.children().filter(menu => menu.isChildActive(url)).length > 0);
}
addChild(child) {
if (!(child instanceof Menu)) {
throw new Error('Only Menu instances are accepted as children of a Menu');
}, {
key: 'isActive',
value: function isActive(url) {
return this._activeFunc(url);
}
this._children.push(child);
return this;
}
hasChild() {
return this._children.length > 0;
}
getChildByTitle(title) {
return this.children().filter(child => child.title() == title).pop();
}
children() {
if (arguments.length) {
this._children = arguments[0];
return this;
}, {
key: 'isChildActive',
value: function isChildActive(url) {
return this.isActive(url) || this.children().filter(function (menu) {
return menu.isChildActive(url);
}).length > 0;
}
return this._children;
}
icon() {
if (arguments.length) {
this._icon = arguments[0];
}, {
key: 'addChild',
value: function addChild(child) {
if (!(child instanceof Menu)) {
throw new Error('Only Menu instances are accepted as children of a Menu');
}
this._children.push(child);
return this;
}
return this._icon;
}
template() {
if (arguments.length) {
this._template = arguments[0];
}, {
key: 'hasChild',
value: function hasChild() {
return this._children.length > 0;
}
}, {
key: 'getChildByTitle',
value: function getChildByTitle(title) {
return this.children().filter(function (child) {
return child.title() == title;
}).pop();
}
}, {
key: 'children',
value: function children() {
if (arguments.length) {
this._children = arguments[0];
return this;
}
return this._children;
}
}, {
key: 'icon',
value: function icon() {
if (arguments.length) {
this._icon = arguments[0];
return this;
}
return this._icon;
}
}, {
key: 'template',
value: function template() {
if (arguments.length) {
this._template = arguments[0];
return this;
}
return this._template;
}
}, {
key: 'populateFromEntity',
value: function populateFromEntity(entity) {
if (!(entity instanceof _EntityEntity2['default'])) {
throw new Error('populateFromEntity() only accepts an Entity parameter');
}
this.title(entity.label());
this.active(function (path) {
return path.indexOf('/' + entity.name() + '/') === 0;
});
this.link('/' + entity.name() + '/list');
// deprecated
this.icon(entity.menuView().icon());
return this;
}
return this._template;
}
}]);
populateFromEntity(entity) {
if (!(entity instanceof Entity)) {
throw new Error('populateFromEntity() only accepts an Entity parameter');
}
this.title(entity.label());
this.active(path => path.indexOf(`/${entity.name()}/`) === 0 );
this.link(`/${entity.name()}/list`);
// deprecated
this.icon(entity.menuView().icon());
return this;
}
}
return Menu;
})();
export default Menu;
exports['default'] = Menu;
module.exports = exports['default'];
//# sourceMappingURL=Menu.js.map

@@ -0,10 +1,19 @@

"use strict";
class Queries {
constructor(RestWrapper, PromisesResolver, Application) {
this._restWrapper = RestWrapper;
this._promisesResolver = PromisesResolver;
this._application = Application;
}
}
Object.defineProperty(exports, "__esModule", {
value: true
});
export default Queries;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Queries = function Queries(RestWrapper, PromisesResolver, Application) {
_classCallCheck(this, Queries);
this._restWrapper = RestWrapper;
this._promisesResolver = PromisesResolver;
this._application = Application;
};
exports["default"] = Queries;
module.exports = exports["default"];
//# sourceMappingURL=Queries.js.map

@@ -1,58 +0,89 @@

import Queries from './Queries';
import ReferenceExtractor from '../Utils/ReferenceExtractor';
'use strict';
class ReadQueries extends Queries {
Object.defineProperty(exports, '__esModule', {
value: true
});
/**
* Get one entity
*
* @param {Entity} entity
* @param {String} viewType
* @param {mixed} identifierValue
* @param {String} identifierName
* @param {String} url
*
* @returns {promise} (list of fields (with their values if set) & the entity name, label & id-
*/
getOne(entity, viewType, identifierValue, identifierName, url) {
return this._restWrapper
.getOne(entity.name(), this._application.getRouteFor(entity, url, viewType, identifierValue, identifierName), entity.retrieveMethod());
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _Queries2 = require('./Queries');
var _Queries3 = _interopRequireDefault(_Queries2);
var _UtilsReferenceExtractor = require('../Utils/ReferenceExtractor');
var _UtilsReferenceExtractor2 = _interopRequireDefault(_UtilsReferenceExtractor);
var ReadQueries = (function (_Queries) {
function ReadQueries() {
_classCallCheck(this, ReadQueries);
if (_Queries != null) {
_Queries.apply(this, arguments);
}
}
/**
* Return the list of all object of entityName type
* Get all the object from the API
*
* @param {ListView} view the view associated to the entity
* @param {Number} page the page number
* @param {Object} filterValues searchQuery to filter elements
* @param {String} sortField the field to be sorted ex: entity.fieldName
* @param {String} sortDir the direction of the sort
*
* @returns {promise} the entity config & the list of objects
*/
getAll(view, page, filterValues, sortField, sortDir) {
page = page || 1;
filterValues = filterValues || {};
let url = view.getUrl();
_inherits(ReadQueries, _Queries);
if (sortField && sortField.split('.')[0] === view.name()) {
sortField = sortField;
sortDir = sortDir;
} else {
sortField = view.getSortFieldName();
sortDir = view.sortDir();
_createClass(ReadQueries, [{
key: 'getOne',
/**
* Get one entity
*
* @param {Entity} entity
* @param {String} viewType
* @param {mixed} identifierValue
* @param {String} identifierName
* @param {String} url
*
* @returns {promise} (list of fields (with their values if set) & the entity name, label & id-
*/
value: function getOne(entity, viewType, identifierValue, identifierName, url) {
return this._restWrapper.getOne(entity.name(), this._application.getRouteFor(entity, url, viewType, identifierValue, identifierName), entity.retrieveMethod());
}
}, {
key: 'getAll',
let allFilterValues = {};
const permanentFilters = view.permanentFilters();
Object.keys(filterValues).forEach(key => {
allFilterValues[key] = filterValues[key];
});
Object.keys(permanentFilters).forEach(key => {
allFilterValues[key] = permanentFilters[key];
});
/**
* Return the list of all object of entityName type
* Get all the object from the API
*
* @param {ListView} view the view associated to the entity
* @param {Number} page the page number
* @param {Object} filterValues searchQuery to filter elements
* @param {String} sortField the field to be sorted ex: entity.fieldName
* @param {String} sortDir the direction of the sort
*
* @returns {promise} the entity config & the list of objects
*/
value: function getAll(view, page, filterValues, sortField, sortDir) {
page = page || 1;
filterValues = filterValues || {};
var url = view.getUrl();
return this.getRawValues(view.entity, view.name(), view.type, page, view.perPage(), allFilterValues, view.filters(), sortField, sortDir, url)
.then((values) => {
if (sortField && sortField.split('.')[0] === view.name()) {
sortField = sortField;
sortDir = sortDir;
} else {
sortField = view.getSortFieldName();
sortDir = view.sortDir();
}
var allFilterValues = {};
var permanentFilters = view.permanentFilters();
Object.keys(filterValues).forEach(function (key) {
allFilterValues[key] = filterValues[key];
});
Object.keys(permanentFilters).forEach(function (key) {
allFilterValues[key] = permanentFilters[key];
});
return this.getRawValues(view.entity, view.name(), view.type, page, view.perPage(), allFilterValues, view.filters(), sortField, sortDir, url).then(function (values) {
return {

@@ -63,66 +94,70 @@ data: values.data,

});
}
}
}, {
key: 'getRawValues',
/**
* Return the list of all object of entityName type
* Get all the object from the API
*
* @param {Entity} entity
* @param {String} viewName
* @param {String} viewType
* @param {Number} page
* @param {Number} perPage
* @param {Object} filterValues
* @param {Object} filterFields
* @param {String} sortField
* @param {String} sortDir
* @param {String} url
*
* @returns {promise} the entity config & the list of objects
*/
getRawValues(entity, viewName, viewType, page, perPage, filterValues, filterFields, sortField, sortDir, url) {
let params = {};
/**
* Return the list of all object of entityName type
* Get all the object from the API
*
* @param {Entity} entity
* @param {String} viewName
* @param {String} viewType
* @param {Number} page
* @param {Number} perPage
* @param {Object} filterValues
* @param {Object} filterFields
* @param {String} sortField
* @param {String} sortDir
* @param {String} url
*
* @returns {promise} the entity config & the list of objects
*/
value: function getRawValues(entity, viewName, viewType, page, perPage, filterValues, filterFields, sortField, sortDir, url) {
var params = {};
// Compute pagination
if (page !== -1) {
params._page = (typeof (page) === 'undefined') ? 1 : parseInt(page, 10);
params._perPage = perPage;
}
// Compute pagination
if (page !== -1) {
params._page = typeof page === 'undefined' ? 1 : parseInt(page, 10);
params._perPage = perPage;
}
// Compute sorting
if (sortField && sortField.split('.')[0] === viewName) {
params._sortField = sortField.substr(sortField.indexOf('.') + 1);
params._sortDir = sortDir;
}
// Compute sorting
if (sortField && sortField.split('.')[0] === viewName) {
params._sortField = sortField.substr(sortField.indexOf('.') + 1);
params._sortDir = sortDir;
}
// Compute filtering
if (filterValues && Object.keys(filterValues).length !== 0) {
params._filters = {};
let filterName, mappedValue;
for (filterName in filterValues) {
if (filterFields.hasOwnProperty(filterName) && filterFields[filterName].hasMaps()) {
mappedValue = filterFields[filterName].getMappedValue(filterValues[filterName]);
Object.keys(mappedValue).forEach(key => {
params._filters[key] = mappedValue[key];
})
continue;
}
// Compute filtering
if (filterValues && Object.keys(filterValues).length !== 0) {
(function () {
params._filters = {};
var filterName = undefined,
mappedValue = undefined;
for (filterName in filterValues) {
if (filterFields.hasOwnProperty(filterName) && filterFields[filterName].hasMaps()) {
mappedValue = filterFields[filterName].getMappedValue(filterValues[filterName]);
Object.keys(mappedValue).forEach(function (key) {
params._filters[key] = mappedValue[key];
});
continue;
}
// It's weird to not map, but why not.
params._filters[filterName] = filterValues[filterName];
// It's weird to not map, but why not.
params._filters[filterName] = filterValues[filterName];
}
})();
}
// Get grid data
return this._restWrapper.getList(params, entity.name(), this._application.getRouteFor(entity, url, viewType), entity.retrieveMethod());
}
// Get grid data
return this._restWrapper
.getList(params, entity.name(), this._application.getRouteFor(entity, url, viewType), entity.retrieveMethod());
}
getReferenceData(references, rawValues) {
var nonOptimizedReferencedData = this.getFilteredReferenceData(ReferenceExtractor.getNonOptimizedReferences(references), rawValues);
var optimizedReferencedData = this.getOptimizedReferenceData(ReferenceExtractor.getOptimizedReferences(references), rawValues);
return Promise.all([nonOptimizedReferencedData, optimizedReferencedData])
.then((results) => {
let data = {};
let name;
}, {
key: 'getReferenceData',
value: function getReferenceData(references, rawValues) {
var nonOptimizedReferencedData = this.getFilteredReferenceData(_UtilsReferenceExtractor2['default'].getNonOptimizedReferences(references), rawValues);
var optimizedReferencedData = this.getOptimizedReferenceData(_UtilsReferenceExtractor2['default'].getOptimizedReferences(references), rawValues);
return Promise.all([nonOptimizedReferencedData, optimizedReferencedData]).then(function (results) {
var data = {};
var name = undefined;
for (name in results[0]) {

@@ -135,137 +170,139 @@ data[name] = results[0][name];

return data;
})
}
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* by calling the API for each entries
*
* @param {ReferenceField} references A hash of Reference and ReferenceMany objects
* @param {Array} rawValues
*
* @returns {Promise}
*/
getFilteredReferenceData(references, rawValues) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
});
}
}, {
key: 'getFilteredReferenceData',
let getOne = this.getOne.bind(this),
calls = [];
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* by calling the API for each entries
*
* @param {ReferenceField} references A hash of Reference and ReferenceMany objects
* @param {Array} rawValues
*
* @returns {Promise}
*/
value: function getFilteredReferenceData(references, rawValues) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
}
for (let i in references) {
let reference = references[i],
targetEntity = reference.targetEntity(),
identifiers = reference.getIdentifierValues(rawValues);
var getOne = this.getOne.bind(this),
calls = [];
for (let k in identifiers) {
calls.push(getOne(targetEntity, 'listView', identifiers[k], reference.name()));
for (var i in references) {
var reference = references[i],
targetEntity = reference.targetEntity(),
identifiers = reference.getIdentifierValues(rawValues);
for (var k in identifiers) {
calls.push(getOne(targetEntity, 'listView', identifiers[k], reference.name()));
}
}
}
return this.fillFilteredReferencedData(calls, references, rawValues);
}
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* by calling the API once
*
* @param {[ReferenceField]} references A hash of Reference and ReferenceMany objects
* @param {Array} rawValues
*
* @returns {Promise}
*/
getOptimizedReferenceData(references, rawValues) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
return this.fillFilteredReferencedData(calls, references, rawValues);
}
}, {
key: 'getOptimizedReferenceData',
let getRawValues = this.getRawValues.bind(this),
calls = [];
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* by calling the API once
*
* @param {[ReferenceField]} references A hash of Reference and ReferenceMany objects
* @param {Array} rawValues
*
* @returns {Promise}
*/
value: function getOptimizedReferenceData(references, rawValues) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
}
for (let i in references) {
let reference = references[i],
targetEntity = reference.targetEntity(),
identifiers = reference.getIdentifierValues(rawValues);
var getRawValues = this.getRawValues.bind(this),
calls = [];
// Check if we should retrieve values with 1 or multiple requests
let singleCallFilters = reference.getSingleApiCall(identifiers);
calls.push(getRawValues(targetEntity, targetEntity.name() + '_ListView', 'listView', 1, reference.perPage(), singleCallFilters, {}, reference.sortField(), reference.sortDir()));
}
for (var i in references) {
var reference = references[i],
targetEntity = reference.targetEntity(),
identifiers = reference.getIdentifierValues(rawValues);
return this.fillOptimizedReferencedData(calls, references);
}
// Check if we should retrieve values with 1 or multiple requests
var singleCallFilters = reference.getSingleApiCall(identifiers);
calls.push(getRawValues(targetEntity, targetEntity.name() + '_ListView', 'listView', 1, reference.perPage(), singleCallFilters, {}, reference.sortField(), reference.sortDir()));
}
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* without filters on an entity
*
* @param {[ReferenceField]} references A hash of Reference and ReferenceMany objects
*
* @returns {Promise}
*/
getAllReferencedData(references, search) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
return this.fillOptimizedReferencedData(calls, references);
}
}, {
key: 'getAllReferencedData',
let calls = [],
getRawValues = this.getRawValues.bind(this);
/**
* Returns all References for an entity with associated values [{targetEntity.identifier: targetLabel}, ...]
* without filters on an entity
*
* @param {[ReferenceField]} references A hash of Reference and ReferenceMany objects
*
* @returns {Promise}
*/
value: function getAllReferencedData(references, search) {
if (!references || !Object.keys(references).length) {
return this._promisesResolver.empty({});
}
for (let i in references) {
let reference = references[i];
let targetEntity = reference.targetEntity();
var calls = [],
getRawValues = this.getRawValues.bind(this);
const permanentFilters = reference.permanentFilters();
let filterValues = permanentFilters || {};
var _loop = function (i) {
var reference = references[i];
var targetEntity = reference.targetEntity();
if (typeof(permanentFilters) === 'function') {
console.warn('Reference.permanentFilters() called with a function is deprecated. Use the searchQuery option for remoteComplete() instead');
filterValues = permanentFilters(search);
}
var permanentFilters = reference.permanentFilters();
var filterValues = permanentFilters || {};
if (search) {
// remote complete situation
let options = reference.remoteCompleteOptions();
if (options.searchQuery) {
let filterValuesFromRemoteComplete = options.searchQuery(search);
Object.keys(filterValuesFromRemoteComplete).forEach(key => {
filterValues[key] = filterValuesFromRemoteComplete[key];
})
} else {
// by default, filter the list by the referenceField name
filterValues[reference.targetField().name()] = search;
if (typeof permanentFilters === 'function') {
console.warn('Reference.permanentFilters() called with a function is deprecated. Use the searchQuery option for remoteComplete() instead');
filterValues = permanentFilters(search);
}
}
let filterFields = {};
filterFields[reference.name()] = reference;
if (search) {
// remote complete situation
var options = reference.remoteCompleteOptions();
if (options.searchQuery) {
(function () {
var filterValuesFromRemoteComplete = options.searchQuery(search);
Object.keys(filterValuesFromRemoteComplete).forEach(function (key) {
filterValues[key] = filterValuesFromRemoteComplete[key];
});
})();
} else {
// by default, filter the list by the referenceField name
filterValues[reference.targetField().name()] = search;
}
}
calls.push(getRawValues(
targetEntity,
targetEntity.name() + '_ListView',
'listView',
1,
reference.perPage(),
filterValues,
filterFields,
reference.getSortFieldName(),
reference.sortDir()
));
var filterFields = {};
filterFields[reference.name()] = reference;
calls.push(getRawValues(targetEntity, targetEntity.name() + '_ListView', 'listView', 1, reference.perPage(), filterValues, filterFields, reference.getSortFieldName(), reference.sortDir()));
};
for (var i in references) {
_loop(i);
}
return this.fillOptimizedReferencedData(calls, references);
}
}, {
key: 'fillOptimizedReferencedData',
return this.fillOptimizedReferencedData(calls, references);
}
/**
* Fill all reference entries to return [{targetEntity.identifier: targetLabel}, ...]
*
* @param {[Promise]} apiCalls
* @param {[Reference]} references
* @returns {Promise}
*/
fillOptimizedReferencedData(apiCalls, references) {
return this._promisesResolver.allEvenFailed(apiCalls)
.then((responses) => {
/**
* Fill all reference entries to return [{targetEntity.identifier: targetLabel}, ...]
*
* @param {[Promise]} apiCalls
* @param {[Reference]} references
* @returns {Promise}
*/
value: function fillOptimizedReferencedData(apiCalls, references) {
return this._promisesResolver.allEvenFailed(apiCalls).then(function (responses) {
if (responses.length === 0) {

@@ -275,7 +312,7 @@ return {};

let referencedData = {},
var referencedData = {},
i = 0;
for (let j in references) {
let reference = references[j],
for (var j in references) {
var reference = references[j],
response = responses[i++];

@@ -294,15 +331,16 @@

});
}
}
}, {
key: 'fillFilteredReferencedData',
/**
* Fill all reference entries to return [{targetEntity.identifier: targetLabel}, ...]
*
* @param {[Promise]} apiCalls
* @param {[Reference]} references
* @param {[Object]} rawValues
* @returns {Promise}
*/
fillFilteredReferencedData(apiCalls, references, rawValues) {
return this._promisesResolver.allEvenFailed(apiCalls)
.then((responses) => {
/**
* Fill all reference entries to return [{targetEntity.identifier: targetLabel}, ...]
*
* @param {[Promise]} apiCalls
* @param {[Reference]} references
* @param {[Object]} rawValues
* @returns {Promise}
*/
value: function fillFilteredReferencedData(apiCalls, references, rawValues) {
return this._promisesResolver.allEvenFailed(apiCalls).then(function (responses) {
if (responses.length === 0) {

@@ -312,12 +350,12 @@ return {};

let referencedData = {},
response,
var referencedData = {},
response = undefined,
i = 0;
for (let j in references) {
let data = [],
for (var j in references) {
var data = [],
reference = references[j],
identifiers = reference.getIdentifierValues(rawValues);
for (let k in identifiers) {
for (var k in identifiers) {
response = responses[i++];

@@ -340,47 +378,52 @@ if (response.status == 'error') {

});
}
}
}, {
key: 'getReferencedListData',
/**
* Returns all ReferencedList for an entity for associated values [{targetEntity.identifier: [targetFields, ...]}}
*
* @param {View} referencedLists
* @param {String} sortField
* @param {String} sortDir
* @param {*} entityId
*
* @returns {promise}
*/
getReferencedListData(referencedLists, sortField, sortDir, entityId) {
let getRawValues = this.getRawValues.bind(this),
calls = [];
/**
* Returns all ReferencedList for an entity for associated values [{targetEntity.identifier: [targetFields, ...]}}
*
* @param {View} referencedLists
* @param {String} sortField
* @param {String} sortDir
* @param {*} entityId
*
* @returns {promise}
*/
value: function getReferencedListData(referencedLists, sortField, sortDir, entityId) {
var getRawValues = this.getRawValues.bind(this),
calls = [];
for (let i in referencedLists) {
let referencedList = referencedLists[i],
targetEntity = referencedList.targetEntity(),
viewName = referencedList.datagridName(),
currentSortField = referencedList.getSortFieldName(),
currentSortDir = referencedList.sortDir(),
filter = {};
var _loop2 = function (i) {
var referencedList = referencedLists[i],
targetEntity = referencedList.targetEntity(),
viewName = referencedList.datagridName(),
currentSortField = referencedList.getSortFieldName(),
currentSortDir = referencedList.sortDir(),
filter = {};
if (sortField && sortField.split('.')[0] === viewName) {
currentSortField = sortField;
currentSortDir = sortDir || 'ASC';
}
if (sortField && sortField.split('.')[0] === viewName) {
currentSortField = sortField;
currentSortDir = sortDir || 'ASC';
}
const permanentFilters = referencedList.permanentFilters() || {};
Object.keys(permanentFilters).forEach(key => {
filter[key] = permanentFilters[key];
});
filter[referencedList.targetReferenceField()] = entityId;
var permanentFilters = referencedList.permanentFilters() || {};
Object.keys(permanentFilters).forEach(function (key) {
filter[key] = permanentFilters[key];
});
filter[referencedList.targetReferenceField()] = entityId;
calls.push(getRawValues(targetEntity, viewName, 'listView', 1, referencedList.perPage(), filter, {}, currentSortField, currentSortDir));
}
calls.push(getRawValues(targetEntity, viewName, 'listView', 1, referencedList.perPage(), filter, {}, currentSortField, currentSortDir));
};
return this._promisesResolver.allEvenFailed(calls)
.then((responses) => {
let j = 0,
for (var i in referencedLists) {
_loop2(i);
}
return this._promisesResolver.allEvenFailed(calls).then(function (responses) {
var j = 0,
entries = {};
for (let i in referencedLists) {
let response = responses[j++];
for (var i in referencedLists) {
var response = responses[j++];
if (response.status == 'error') {

@@ -396,16 +439,31 @@ // If a response fail, skip it

});
}
}
}, {
key: 'getRecordsByIds',
value: function getRecordsByIds(entity, ids) {
var _this = this;
getRecordsByIds(entity, ids) {
if (!ids || !ids.length) {
return this._promisesResolver.empty();
if (!ids || !ids.length) {
return this._promisesResolver.empty();
}
var calls = ids.map(function (id) {
return _this.getOne(entity, 'listView', id, entity.identifier().name());
});
return this._promisesResolver.allEvenFailed(calls).then(function (responses) {
return responses.filter(function (r) {
return r.status != 'error';
}).map(function (r) {
return r.result;
});
});
}
}]);
let calls = ids.map(id => this.getOne(entity, 'listView', id, entity.identifier().name()));
return ReadQueries;
})(_Queries3['default']);
return this._promisesResolver.allEvenFailed(calls)
.then(responses => responses.filter(r => r.status != 'error').map(r => r.result));
}
}
export default ReadQueries;
exports['default'] = ReadQueries;
module.exports = exports['default'];
//# sourceMappingURL=ReadQueries.js.map

@@ -1,70 +0,106 @@

import Queries from './Queries'
'use strict';
class WriteQueries extends Queries {
Object.defineProperty(exports, '__esModule', {
value: true
});
/**
* Create a new entity
* Post the data to the API to create the new object
*
* @param {View} view the formView related to the entity
* @param {Object} rawEntity the entity's object
*
* @returns {promise} the new object
*/
createOne(view, rawEntity) {
return this._restWrapper
.createOne(rawEntity, view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(), view.type), view.entity.createMethod());
}
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
/**
* Update an entity
* Put the data to the API to create the new object
*
* @param {View} view the formView related to the entity
* @param {Object} rawEntity the entity's object
* @param {String} originEntityId if entity identifier is modified
*
* @returns {promise} the updated object
*/
updateOne(view, rawEntity, originEntityId) {
let entityId = originEntityId || rawEntity[view.entity.identifier().name()];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
// Update element data
return this._restWrapper
.updateOne(rawEntity, view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier()), view.entity.updateMethod());
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/**
* Delete an entity
* Delete the data to the API
*
* @param {String} view the formView related to the entity
* @param {*} entityId the entity's id
*
* @returns {promise}
*/
deleteOne(view, entityId) {
return this._restWrapper
.deleteOne(view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier()), view.entity.deleteMethod());
}
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
/**
* Delete a batch of entity
* Delete the data to the API
*
* @param {String} view the formView related to the entity
* @param {*} entityIds the entities ids
*
* @returns {promise}
*/
batchDelete(view, entityIds) {
let deleteOne = this.deleteOne.bind(this)
let promises = entityIds.map(function (id) {
return deleteOne(view, id);
});
var _Queries2 = require('./Queries');
return this._promisesResolver.allEvenFailed(promises);
var _Queries3 = _interopRequireDefault(_Queries2);
var WriteQueries = (function (_Queries) {
function WriteQueries() {
_classCallCheck(this, WriteQueries);
if (_Queries != null) {
_Queries.apply(this, arguments);
}
}
}
export default WriteQueries
_inherits(WriteQueries, _Queries);
_createClass(WriteQueries, [{
key: 'createOne',
/**
* Create a new entity
* Post the data to the API to create the new object
*
* @param {View} view the formView related to the entity
* @param {Object} rawEntity the entity's object
*
* @returns {promise} the new object
*/
value: function createOne(view, rawEntity) {
return this._restWrapper.createOne(rawEntity, view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(), view.type), view.entity.createMethod());
}
}, {
key: 'updateOne',
/**
* Update an entity
* Put the data to the API to create the new object
*
* @param {View} view the formView related to the entity
* @param {Object} rawEntity the entity's object
* @param {String} originEntityId if entity identifier is modified
*
* @returns {promise} the updated object
*/
value: function updateOne(view, rawEntity, originEntityId) {
var entityId = originEntityId || rawEntity[view.entity.identifier().name()];
// Update element data
return this._restWrapper.updateOne(rawEntity, view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier()), view.entity.updateMethod());
}
}, {
key: 'deleteOne',
/**
* Delete an entity
* Delete the data to the API
*
* @param {String} view the formView related to the entity
* @param {*} entityId the entity's id
*
* @returns {promise}
*/
value: function deleteOne(view, entityId) {
return this._restWrapper.deleteOne(view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier()), view.entity.deleteMethod());
}
}, {
key: 'batchDelete',
/**
* Delete a batch of entity
* Delete the data to the API
*
* @param {String} view the formView related to the entity
* @param {*} entityIds the entities ids
*
* @returns {promise}
*/
value: function batchDelete(view, entityIds) {
var deleteOne = this.deleteOne.bind(this);
var promises = entityIds.map(function (id) {
return deleteOne(view, id);
});
return this._promisesResolver.allEvenFailed(promises);
}
}]);
return WriteQueries;
})(_Queries3['default']);
exports['default'] = WriteQueries;
module.exports = exports['default'];
//# sourceMappingURL=WriteQueries.js.map

@@ -0,1 +1,9 @@

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.clone = clone;
exports.cloneAndFlatten = cloneAndFlatten;
exports.cloneAndNest = cloneAndNest;
function isObject(value) {

@@ -9,4 +17,4 @@ if (value === null) return false;

export function clone(object) {
return Object.keys(object).reduce((values, name) => {
function clone(object) {
return Object.keys(object).reduce(function (values, name) {
if (object.hasOwnProperty(name)) {

@@ -31,15 +39,20 @@ values[name] = object[name];

*/
export function cloneAndFlatten(object, excludedProperties = []) {
function cloneAndFlatten(object) {
var excludedProperties = arguments[1] === undefined ? [] : arguments[1];
if (typeof object !== 'object') {
throw new Error('Expecting an object parameter');
}
return Object.keys(object).reduce((values, name) => {
return Object.keys(object).reduce(function (values, name) {
if (!object.hasOwnProperty(name)) return values;
if (isObject(object[name])) {
if (excludedProperties.indexOf(name) === -1) {
let flatObject = cloneAndFlatten(object[name]);
Object.keys(flatObject).forEach(flatObjectKey => {
if (!flatObject.hasOwnProperty(flatObjectKey)) return;
values[name + '.' + flatObjectKey] = flatObject[flatObjectKey];
})
(function () {
var flatObject = cloneAndFlatten(object[name]);
Object.keys(flatObject).forEach(function (flatObjectKey) {
if (!flatObject.hasOwnProperty(flatObjectKey)) return;
values[name + '.' + flatObjectKey] = flatObject[flatObjectKey];
});
})();
} else {

@@ -53,4 +66,6 @@ values[name] = clone(object[name]);

}, {});
};
}
;
/*

@@ -67,12 +82,13 @@ * Clone flattened object into a nested object

*/
export function cloneAndNest(object) {
function cloneAndNest(object) {
if (typeof object !== 'object') {
throw new Error('Expecting an object parameter');
}
return Object.keys(object).reduce((values, name) => {
return Object.keys(object).reduce(function (values, name) {
if (!object.hasOwnProperty(name)) return values;
name.split('.').reduce((previous, current, index, list) => {
name.split('.').reduce(function (previous, current, index, list) {
if (previous != null) {
if (typeof previous[current] === 'undefined') previous[current] = {};
if (index < (list.length - 1)) {
if (index < list.length - 1) {
return previous[current];

@@ -82,5 +98,6 @@ };

}
}, values)
}, values);
return values;
}, {})
}, {});
}
//# sourceMappingURL=objectProperties.js.map

@@ -1,3 +0,8 @@

export default {
order: function (input) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = {
order: function order(input) {
var results = [],

@@ -10,4 +15,8 @@ objectKey;

return results.sort((e1, e2) => e1.order() - e2.order());
return results.sort(function (e1, e2) {
return e1.order() - e2.order();
});
}
};
module.exports = exports["default"];
//# sourceMappingURL=orderElement.js.map

@@ -0,54 +1,75 @@

'use strict';
class PromisesResolver {
static empty(value) {
return new Promise((resolve) => {
resolve(value);
});
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var PromisesResolver = (function () {
function PromisesResolver() {
_classCallCheck(this, PromisesResolver);
}
static allEvenFailed(promises) {
if (!Array.isArray(promises)) {
throw Error('allEvenFailed can only handle an array of promises');
_createClass(PromisesResolver, null, [{
key: 'empty',
value: function empty(value) {
return new Promise(function (resolve) {
resolve(value);
});
}
return new Promise((resolve, reject) => {
if (promises.length === 0) {
return resolve([]);
}, {
key: 'allEvenFailed',
value: function allEvenFailed(promises) {
if (!Array.isArray(promises)) {
throw Error('allEvenFailed can only handle an array of promises');
}
let states = [],
results = [];
return new Promise(function (resolve, reject) {
if (promises.length === 0) {
return resolve([]);
}
promises.forEach((promise, key) => {
states[key] = false; // promises are not resolved by default
});
var states = [],
results = [];
promises.forEach((promise, key) => {
function resolveState(result) {
states[key] = true;
results[key] = result; // result may be an error
for (let i in states) {
if (!states[i]) {
return;
promises.forEach(function (promise, key) {
states[key] = false; // promises are not resolved by default
});
promises.forEach(function (promise, key) {
function resolveState(result) {
states[key] = true;
results[key] = result; // result may be an error
for (var i in states) {
if (!states[i]) {
return;
}
}
resolve(results);
}
resolve(results);
}
function resolveSuccess(result) {
return resolveState({ status: 'success', result: result });
}
function resolveSuccess(result) {
return resolveState({status: 'success', result: result});
}
function resolveError(result) {
return resolveState({ status: 'error', error: result });
}
function resolveError(result) {
return resolveState({status: 'error', error: result})
}
// whether the promise ends with success or error, consider it done
promise.then(resolveSuccess, resolveError);
// whether the promise ends with success or error, consider it done
promise.then(resolveSuccess, resolveError);
});
});
});
}
}
}
}]);
export default PromisesResolver;
return PromisesResolver;
})();
exports['default'] = PromisesResolver;
module.exports = exports['default'];
//# sourceMappingURL=PromisesResolver.js.map

@@ -1,26 +0,43 @@

export default {
'use strict';
getReferencedLists(fields) {
return this.indexByName(fields.filter(f => f.type() === 'referenced_list'));
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = {
getReferencedLists: function getReferencedLists(fields) {
return this.indexByName(fields.filter(function (f) {
return f.type() === 'referenced_list';
}));
},
getReferences(fields, withRemoteComplete, optimized = null) {
let references = fields.filter(f => f.type() === 'reference' || f.type() === 'reference_many');
getReferences: function getReferences(fields, withRemoteComplete) {
var optimized = arguments[2] === undefined ? null : arguments[2];
var references = fields.filter(function (f) {
return f.type() === 'reference' || f.type() === 'reference_many';
});
if (withRemoteComplete === true) {
references = references.filter(r => r.remoteComplete());
references = references.filter(function (r) {
return r.remoteComplete();
});
} else if (withRemoteComplete === false) {
references = references.filter(r => !r.remoteComplete());
references = references.filter(function (r) {
return !r.remoteComplete();
});
}
if (optimized !== null) {
references = references.filter(r => r.hasSingleApiCall() === optimized)
references = references.filter(function (r) {
return r.hasSingleApiCall() === optimized;
});
}
return this.indexByName(references);
},
getNonOptimizedReferences(fields, withRemoteComplete) {
getNonOptimizedReferences: function getNonOptimizedReferences(fields, withRemoteComplete) {
return this.getReferences(fields, withRemoteComplete, false);
},
getOptimizedReferences(fields, withRemoteComplete) {
getOptimizedReferences: function getOptimizedReferences(fields, withRemoteComplete) {
return this.getReferences(fields, withRemoteComplete, true);
},
indexByName(references) {
return references.reduce((referencesByName, reference) => {
indexByName: function indexByName(references) {
return references.reduce(function (referencesByName, reference) {
referencesByName[reference.name()] = reference;

@@ -31,1 +48,3 @@ return referencesByName;

};
module.exports = exports['default'];
//# sourceMappingURL=ReferenceExtractor.js.map

@@ -1,2 +0,7 @@

export default {
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = {
/**

@@ -6,3 +11,3 @@ * @see http://stackoverflow.com/questions/10425287/convert-string-to-camelcase-with-regular-expression

*/
camelCase: function(text) {
camelCase: function camelCase(text) {
if (!text) {

@@ -12,3 +17,3 @@ return text;

let f = text.charAt(0).toUpperCase();
var f = text.charAt(0).toUpperCase();
text = f + text.substr(1);

@@ -21,1 +26,3 @@

};
module.exports = exports['default'];
//# sourceMappingURL=stringUtils.js.map

@@ -1,12 +0,36 @@

import View from './View';
'use strict';
class BatchDeleteView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var BatchDeleteView = (function (_View) {
function BatchDeleteView(name) {
_classCallCheck(this, BatchDeleteView);
_get(Object.getPrototypeOf(BatchDeleteView.prototype), 'constructor', this).call(this, name);
this._type = 'BatchDeleteView';
this._enabled = true;
}
}
export default BatchDeleteView;
_inherits(BatchDeleteView, _View);
return BatchDeleteView;
})(_View3['default']);
exports['default'] = BatchDeleteView;
module.exports = exports['default'];
//# sourceMappingURL=BatchDeleteView.js.map

@@ -1,6 +0,26 @@

import View from './View';
'use strict';
class CreateView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var CreateView = (function (_View) {
function CreateView(name) {
_classCallCheck(this, CreateView);
_get(Object.getPrototypeOf(CreateView.prototype), 'constructor', this).call(this, name);
this._type = 'CreateView';

@@ -11,100 +31,112 @@ this._submitCreationSuccess = null;

/**
* Add a function to be executed after the creation succeeds.
*
* This is the ideal place to use the response to update the entry, or
* redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* If the function throws an exception, the onSubmitError callback will
* execute.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.creationView().onSubmitSuccess(['progression', 'notification', '$state', 'entry', 'entity', function(progression, notification, $state, entry, entity) {
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Element #${entry._identifierValue} successfully created.`, { addnCls: 'humane-flatty-success' });
* // redirect to the list view
* $state.go($state.get('list'), { entity: entity.name() });
* // cancel the default action (redirect to the edition view)
* return false;
* }])
*
*/
onSubmitSuccess(onSubmitSuccess) {
if (!arguments.length) return this._onSubmitSuccess;
this._onSubmitSuccess = onSubmitSuccess;
return this;
}
_inherits(CreateView, _View);
/**
* Add a function to be executed after the creation request receives a
* failed http response from the server.
*
* This is the ideal place to use the response to update the entry, display
* server-side validation error, or redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - error: the response from the server
* - errorMessage: the error message based on the response
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.creationView().onSubmitError(['error', 'form', 'progression', 'notification', function(error, form, progression, notification) {
* // mark fields based on errors from the response
* error.violations.forEach(violation => {
* if (form[violation.propertyPath]) {
* form[violation.propertyPath].$valid = false;
* }
* });
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Some values are invalid, see details in the form`, { addnCls: 'humane-flatty-error' });
* // cancel the default action (default error messages)
* return false;
* }]);
*/
onSubmitError(onSubmitError) {
if (!arguments.length) return this._onSubmitError;
this._onSubmitError = onSubmitError;
return this;
}
}
_createClass(CreateView, [{
key: 'onSubmitSuccess',
export default CreateView;
/**
* Add a function to be executed after the creation succeeds.
*
* This is the ideal place to use the response to update the entry, or
* redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* If the function throws an exception, the onSubmitError callback will
* execute.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.creationView().onSubmitSuccess(['progression', 'notification', '$state', 'entry', 'entity', function(progression, notification, $state, entry, entity) {
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Element #${entry._identifierValue} successfully created.`, { addnCls: 'humane-flatty-success' });
* // redirect to the list view
* $state.go($state.get('list'), { entity: entity.name() });
* // cancel the default action (redirect to the edition view)
* return false;
* }])
*
*/
value: function onSubmitSuccess(_onSubmitSuccess) {
if (!arguments.length) return this._onSubmitSuccess;
this._onSubmitSuccess = _onSubmitSuccess;
return this;
}
}, {
key: 'onSubmitError',
/**
* Add a function to be executed after the creation request receives a
* failed http response from the server.
*
* This is the ideal place to use the response to update the entry, display
* server-side validation error, or redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - error: the response from the server
* - errorMessage: the error message based on the response
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.creationView().onSubmitError(['error', 'form', 'progression', 'notification', function(error, form, progression, notification) {
* // mark fields based on errors from the response
* error.violations.forEach(violation => {
* if (form[violation.propertyPath]) {
* form[violation.propertyPath].$valid = false;
* }
* });
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Some values are invalid, see details in the form`, { addnCls: 'humane-flatty-error' });
* // cancel the default action (default error messages)
* return false;
* }]);
*/
value: function onSubmitError(_onSubmitError) {
if (!arguments.length) return this._onSubmitError;
this._onSubmitError = _onSubmitError;
return this;
}
}]);
return CreateView;
})(_View3['default']);
exports['default'] = CreateView;
module.exports = exports['default'];
//# sourceMappingURL=CreateView.js.map

@@ -1,13 +0,46 @@

import ListView from './ListView';
'use strict';
class DashboardView extends ListView {
setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name();
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ListView2 = require('./ListView');
var _ListView3 = _interopRequireDefault(_ListView2);
var DashboardView = (function (_ListView) {
function DashboardView() {
_classCallCheck(this, DashboardView);
if (_ListView != null) {
_ListView.apply(this, arguments);
}
return this;
}
}
export default DashboardView;
_inherits(DashboardView, _ListView);
_createClass(DashboardView, [{
key: 'setEntity',
value: function setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name();
}
return this;
}
}]);
return DashboardView;
})(_ListView3['default']);
exports['default'] = DashboardView;
module.exports = exports['default'];
//# sourceMappingURL=DashboardView.js.map

@@ -1,11 +0,35 @@

import View from './View';
'use strict';
class DeleteView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var DeleteView = (function (_View) {
function DeleteView(name) {
_classCallCheck(this, DeleteView);
_get(Object.getPrototypeOf(DeleteView.prototype), 'constructor', this).call(this, name);
this._type = 'DeleteView';
this._enabled = true;
}
}
export default DeleteView;
_inherits(DeleteView, _View);
return DeleteView;
})(_View3['default']);
exports['default'] = DeleteView;
module.exports = exports['default'];
//# sourceMappingURL=DeleteView.js.map

@@ -1,6 +0,26 @@

import View from './View';
'use strict';
class EditView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var EditView = (function (_View) {
function EditView(name) {
_classCallCheck(this, EditView);
_get(Object.getPrototypeOf(EditView.prototype), 'constructor', this).call(this, name);
this._type = 'EditView';

@@ -11,99 +31,111 @@ this._submitCreationSuccess = null;

/**
* Add a function to be executed after the update succeeds.
*
* This is the ideal place to use the response to update the entry, or
* redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* If the function throws an exception, the onSubmitError callback will
* execute.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.editionView().onSubmitSuccess(['progression', 'notification', '$state', 'entry', 'entity', function(progression, notification, $state, entry, entity) {
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Element #${entry._identifierValue} successfully edited.`, { addnCls: 'humane-flatty-success' });
* // redirect to the list view
* $state.go($state.get('list'), { entity: entity.name() });
* // cancel the default action (redirect to the edition view)
* return false;
* }])
*/
onSubmitSuccess(onSubmitSuccess) {
if (!arguments.length) return this._onSubmitSuccess;
this._onSubmitSuccess = onSubmitSuccess;
return this;
}
_inherits(EditView, _View);
/**
* Add a function to be executed after the update request receives a failed
* http response from the server.
*
* This is the ideal place to use the response to update the entry, display
* server-side validation error, or redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - error: the response from the server
* - errorMessage: the error message based on the response
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.editionView().onSubmitError(['error', 'form', 'progression', 'notification', function(error, form, progression, notification) {
* // mark fields based on errors from the response
* error.violations.forEach(violation => {
* if (form[violation.propertyPath]) {
* form[violation.propertyPath].$valid = false;
* }
* });
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Some values are invalid, see details in the form`, { addnCls: 'humane-flatty-error' });
* // cancel the default action (default error messages)
* return false;
* }]);
*/
onSubmitError(onSubmitError) {
if (!arguments.length) return this._onSubmitError;
this._onSubmitError = onSubmitError;
return this;
}
}
_createClass(EditView, [{
key: 'onSubmitSuccess',
export default EditView;
/**
* Add a function to be executed after the update succeeds.
*
* This is the ideal place to use the response to update the entry, or
* redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* If the function throws an exception, the onSubmitError callback will
* execute.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.editionView().onSubmitSuccess(['progression', 'notification', '$state', 'entry', 'entity', function(progression, notification, $state, entry, entity) {
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Element #${entry._identifierValue} successfully edited.`, { addnCls: 'humane-flatty-success' });
* // redirect to the list view
* $state.go($state.get('list'), { entity: entity.name() });
* // cancel the default action (redirect to the edition view)
* return false;
* }])
*/
value: function onSubmitSuccess(_onSubmitSuccess) {
if (!arguments.length) return this._onSubmitSuccess;
this._onSubmitSuccess = _onSubmitSuccess;
return this;
}
}, {
key: 'onSubmitError',
/**
* Add a function to be executed after the update request receives a failed
* http response from the server.
*
* This is the ideal place to use the response to update the entry, display
* server-side validation error, or redirect to another view.
*
* If the function returns false, the default execution workflow is stopped.
* This means that the function must provide a custom workflow.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - $event: the form submission event
* - error: the response from the server
* - errorMessage: the error message based on the response
* - entry: the current Entry instance
* - entity: the current entity
* - form: the form object (for form validation and errors)
* - progression: the controller for the loading indicator
* - notification: the controller for top notifications
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.editionView().onSubmitError(['error', 'form', 'progression', 'notification', function(error, form, progression, notification) {
* // mark fields based on errors from the response
* error.violations.forEach(violation => {
* if (form[violation.propertyPath]) {
* form[violation.propertyPath].$valid = false;
* }
* });
* // stop the progress bar
* progression.done();
* // add a notification
* notification.log(`Some values are invalid, see details in the form`, { addnCls: 'humane-flatty-error' });
* // cancel the default action (default error messages)
* return false;
* }]);
*/
value: function onSubmitError(_onSubmitError) {
if (!arguments.length) return this._onSubmitError;
this._onSubmitError = _onSubmitError;
return this;
}
}]);
return EditView;
})(_View3['default']);
exports['default'] = EditView;
module.exports = exports['default'];
//# sourceMappingURL=EditView.js.map

@@ -1,11 +0,35 @@

import ListView from './ListView';
'use strict';
class ExportView extends ListView {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _ListView2 = require('./ListView');
var _ListView3 = _interopRequireDefault(_ListView2);
var ExportView = (function (_ListView) {
function ExportView(name) {
_classCallCheck(this, ExportView);
_get(Object.getPrototypeOf(ExportView.prototype), 'constructor', this).call(this, name);
this._fields = [];
this._type = 'ExportView';
}
}
export default ExportView;
_inherits(ExportView, _ListView);
return ExportView;
})(_ListView3['default']);
exports['default'] = ExportView;
module.exports = exports['default'];
//# sourceMappingURL=ExportView.js.map

@@ -1,8 +0,31 @@

import View from './View';
import orderElement from "../Utils/orderElement";
'use strict';
class ListView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var _UtilsOrderElement = require('../Utils/orderElement');
var _UtilsOrderElement2 = _interopRequireDefault(_UtilsOrderElement);
var ListView = (function (_View) {
function ListView(name) {
_classCallCheck(this, ListView);
_get(Object.getPrototypeOf(ListView.prototype), 'constructor', this).call(this, name);
this._type = 'ListView';

@@ -23,185 +46,222 @@ this._perPage = 30;

perPage() {
if (!arguments.length) { return this._perPage; }
this._perPage = arguments[0];
return this;
}
_inherits(ListView, _View);
/** @deprecated Use perPage instead */
limit() {
if (!arguments.length) { return this.perPage(); }
return this.perPage(arguments[0]);
}
sortField() {
if (arguments.length) {
this._sortField = arguments[0];
_createClass(ListView, [{
key: 'perPage',
value: function perPage() {
if (!arguments.length) {
return this._perPage;
}
this._perPage = arguments[0];
return this;
}
}, {
key: 'limit',
return this._sortField;
}
/** @deprecated Use perPage instead */
value: function limit() {
if (!arguments.length) {
return this.perPage();
}
return this.perPage(arguments[0]);
}
}, {
key: 'sortField',
value: function sortField() {
if (arguments.length) {
this._sortField = arguments[0];
return this;
}
sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
return this._sortField;
}
}, {
key: 'sortDir',
value: function sortDir() {
if (arguments.length) {
this._sortDir = arguments[0];
return this;
}
return this._sortDir;
}
return this._sortDir;
}
}, {
key: 'getSortFieldName',
value: function getSortFieldName() {
return this.name() + '.' + this._sortField;
}
}, {
key: 'infinitePagination',
value: function infinitePagination() {
if (arguments.length) {
this._infinitePagination = arguments[0];
return this;
}
getSortFieldName() {
return this.name() + '.' + this._sortField;
}
infinitePagination() {
if (arguments.length) {
this._infinitePagination = arguments[0];
return this;
return this._infinitePagination;
}
}, {
key: 'actions',
value: function actions(_actions) {
if (!arguments.length) {
return this._actions;
}
return this._infinitePagination;
}
this._actions = _actions;
actions(actions) {
if (!arguments.length) {
return this._actions;
return this;
}
}, {
key: 'exportFields',
value: function exportFields(_exportFields) {
if (!arguments.length) {
return this._exportFields;
}
this._actions = actions;
this._exportFields = _exportFields;
return this;
}
exportFields(exportFields) {
if (!arguments.length) {
return this._exportFields;
return this;
}
}, {
key: 'exportOptions',
value: function exportOptions(_exportOptions) {
if (!arguments.length) {
return this._exportOptions;
}
this._exportFields = exportFields;
this._exportOptions = _exportOptions;
return this;
}
exportOptions(exportOptions) {
if (!arguments.length) {
return this._exportOptions;
return this;
}
}, {
key: 'batchActions',
value: function batchActions(actions) {
if (!arguments.length) {
return this._batchActions;
}
this._exportOptions = exportOptions;
this._batchActions = actions;
return this;
}
batchActions(actions) {
if (!arguments.length) {
return this._batchActions;
return this;
}
}, {
key: 'permanentFilters',
this._batchActions = actions;
/**
* Define permanent filters to be added to the REST API calls
*
* posts.listView().permanentFilters({
* published: true
* });
* // related API call will be /posts?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
value: function permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
}
return this;
}
this._permanentFilters = filters;
/**
* Define permanent filters to be added to the REST API calls
*
* posts.listView().permanentFilters({
* published: true
* });
* // related API call will be /posts?published=true
*
* @param {Object} filters list of filters to apply to the call
*/
permanentFilters(filters) {
if (!arguments.length) {
return this._permanentFilters;
return this;
}
}, {
key: 'filters',
this._permanentFilters = filters;
/**
* Define filters the user can add to the datagrid
*
* posts.listView().filters([
* nga.field('title'),
* nga.field('age', 'number')
* ]);
*
* @param {Field[]} filters list of filters to add to the GUI
*/
value: function filters(_filters) {
if (!arguments.length) {
return this._filters;
}
return this;
}
this._filters = _UtilsOrderElement2['default'].order(_filters);
/**
* Define filters the user can add to the datagrid
*
* posts.listView().filters([
* nga.field('title'),
* nga.field('age', 'number')
* ]);
*
* @param {Field[]} filters list of filters to add to the GUI
*/
filters(filters) {
if (!arguments.length) {
return this._filters;
return this;
}
}, {
key: 'getFilterReferences',
value: function getFilterReferences(withRemoteComplete) {
var result = {};
var lists = this._filters.filter(function (f) {
return f.type() === 'reference';
});
this._filters = orderElement.order(filters);
var filterFunction = null;
if (withRemoteComplete === true) {
filterFunction = function (f) {
return f.remoteComplete();
};
} else if (withRemoteComplete === false) {
filterFunction = function (f) {
return !f.remoteComplete();
};
}
return this;
}
if (filterFunction !== null) {
lists = lists.filter(filterFunction);
}
getFilterReferences(withRemoteComplete) {
let result = {};
let lists = this._filters.filter(f => f.type() === 'reference');
for (var i = 0, c = lists.length; i < c; i++) {
var list = lists[i];
result[list.name()] = list;
}
var filterFunction = null;
if (withRemoteComplete === true) {
filterFunction = f => f.remoteComplete();
} else if (withRemoteComplete === false) {
filterFunction = f => !f.remoteComplete();
return result;
}
}, {
key: 'listActions',
value: function listActions(actions) {
if (!arguments.length) {
return this._listActions;
}
if (filterFunction !== null) {
lists = lists.filter(filterFunction);
}
this._listActions = actions;
for (let i = 0, c = lists.length ; i < c ; i++) {
let list = lists[i];
result[list.name()] = list;
return this;
}
}, {
key: 'entryCssClasses',
value: function entryCssClasses(classes) {
if (!arguments.length) {
return this._entryCssClasses;
}
return result;
}
this._entryCssClasses = classes;
listActions(actions) {
if (!arguments.length) {
return this._listActions;
return this;
}
}, {
key: 'getEntryCssClasses',
value: function getEntryCssClasses(entry) {
if (!this._entryCssClasses) {
return '';
}
this._listActions = actions;
if (this._entryCssClasses.constructor === Array) {
return this._entryCssClasses.join(' ');
}
return this;
}
if (typeof this._entryCssClasses === 'function') {
return this._entryCssClasses(entry);
}
entryCssClasses(classes) {
if (!arguments.length) {
return this._entryCssClasses;
}
}]);
this._entryCssClasses = classes;
return ListView;
})(_View3['default']);
return this;
}
getEntryCssClasses(entry) {
if (!this._entryCssClasses) {
return '';
}
if (this._entryCssClasses.constructor === Array) {
return this._entryCssClasses.join(' ');
}
if (typeof(this._entryCssClasses) === 'function') {
return this._entryCssClasses(entry);
}
return this._entryCssClasses;
}
}
export default ListView;
exports['default'] = ListView;
module.exports = exports['default'];
//# sourceMappingURL=ListView.js.map

@@ -1,6 +0,26 @@

import View from "./View";
'use strict';
class MenuView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var MenuView = (function (_View) {
function MenuView(name) {
_classCallCheck(this, MenuView);
_get(Object.getPrototypeOf(MenuView.prototype), 'constructor', this).call(this, name);
this._type = 'MenuView';

@@ -10,21 +30,31 @@ this._icon = null;

get enabled() {
return this._enabled || this.entity.views['ListView'].enabled;
}
_inherits(MenuView, _View);
icon() {
if (arguments.length) {
console.warn('entity.menuView() is deprecated. Please use the Menu class instead');
this._icon = arguments[0];
return this;
}
_createClass(MenuView, [{
key: 'icon',
value: function icon() {
if (arguments.length) {
console.warn('entity.menuView() is deprecated. Please use the Menu class instead');
this._icon = arguments[0];
return this;
}
if (this._icon === null) {
return '<span class="glyphicon glyphicon-list"></span>';
if (this._icon === null) {
return '<span class="glyphicon glyphicon-list"></span>';
}
return this._icon;
}
}, {
key: 'enabled',
get: function () {
return this._enabled || this.entity.views['ListView'].enabled;
}
}]);
return this._icon;
}
}
return MenuView;
})(_View3['default']);
export default MenuView;
exports['default'] = MenuView;
module.exports = exports['default'];
//# sourceMappingURL=MenuView.js.map

@@ -1,10 +0,34 @@

import View from './View';
'use strict';
class ShowView extends View {
constructor(name) {
super(name);
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _View2 = require('./View');
var _View3 = _interopRequireDefault(_View2);
var ShowView = (function (_View) {
function ShowView(name) {
_classCallCheck(this, ShowView);
_get(Object.getPrototypeOf(ShowView.prototype), 'constructor', this).call(this, name);
this._type = 'ShowView';
}
}
export default ShowView;
_inherits(ShowView, _View);
return ShowView;
})(_View3['default']);
exports['default'] = ShowView;
module.exports = exports['default'];
//# sourceMappingURL=ShowView.js.map

@@ -1,7 +0,27 @@

import Entry from '../Entry';
import ReferenceExtractor from '../Utils/ReferenceExtractor';
import { clone, cloneAndFlatten, cloneAndNest } from '../Utils/objectProperties';
'use strict';
class View {
constructor(name) {
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _Entry = require('../Entry');
var _Entry2 = _interopRequireDefault(_Entry);
var _UtilsReferenceExtractor = require('../Utils/ReferenceExtractor');
var _UtilsReferenceExtractor2 = _interopRequireDefault(_UtilsReferenceExtractor);
var _UtilsObjectProperties = require('../Utils/objectProperties');
var View = (function () {
function View(name) {
_classCallCheck(this, View);
this.entity = null;

@@ -23,288 +43,347 @@ this._actions = null;

get enabled() {
return this._enabled || !!this._fields.length;
}
_createClass(View, [{
key: 'title',
value: function title(_title) {
if (!arguments.length) return this._title;
this._title = _title;
return this;
}
}, {
key: 'description',
value: function description() {
if (arguments.length) {
this._description = arguments[0];
return this;
}
title(title) {
if (!arguments.length) return this._title;
this._title = title;
return this;
}
return this._description;
}
}, {
key: 'name',
value: function name(_name) {
if (!arguments.length) {
return this._name || this.entity.name() + '_' + this._type;
}
description() {
if (arguments.length) {
this._description = arguments[0];
this._name = _name;
return this;
}
}, {
key: 'disable',
value: function disable() {
this._enabled = false;
return this._description;
}
return this;
}
}, {
key: 'enable',
value: function enable() {
this._enabled = true;
name(name) {
if (!arguments.length) {
return this._name || this.entity.name() + '_' + this._type;
return this;
}
}, {
key: 'isEnabled',
this._name = name;
return this;
}
/**
* @deprecated Use getter "enabled" instead
*/
value: function isEnabled() {
return this.enabled;
}
}, {
key: 'getEntity',
disable() {
this._enabled = false;
/**
* @deprecated Use getter "entity" instead
*/
value: function getEntity() {
return this.entity;
}
}, {
key: 'setEntity',
return this;
}
/**
* @deprecated Specify entity at view creation or use "entity" setter instead
*/
value: function setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name() + '_' + this._type;
}
enable() {
this._enabled = true;
return this;
}
}, {
key: 'fields',
return this;
}
/*
* Supports various syntax
* fields([ Field1, Field2 ])
* fields(Field1, Field2)
* fields([Field1, {Field2, Field3}])
* fields(Field1, {Field2, Field3})
* fields({Field2, Field3})
*/
value: function fields() {
if (!arguments.length) return this._fields;
/**
* @deprecated Use getter "enabled" instead
*/
isEnabled() {
return this.enabled;
}
[].slice.call(arguments).map(function (argument) {
var _this = this;
/**
* @deprecated Use getter "entity" instead
*/
getEntity() {
return this.entity;
}
View.flatten(argument).map(function (arg) {
return _this.addField(arg);
});
}, this);
/**
* @deprecated Specify entity at view creation or use "entity" setter instead
*/
setEntity(entity) {
this.entity = entity;
if (!this._name) {
this._name = entity.name() + '_' + this._type;
return this;
}
}, {
key: 'hasFields',
value: function hasFields() {
return this.fields.length > 0;
}
}, {
key: 'removeFields',
value: function removeFields() {
this._fields = [];
return this;
}
}, {
key: 'getFields',
value: function getFields() {
return this._fields;
}
}, {
key: 'getField',
value: function getField(fieldName) {
return this._fields.filter(function (f) {
return f.name() === fieldName;
})[0];
}
}, {
key: 'getFieldsOfType',
value: function getFieldsOfType(type) {
return this._fields.filter(function (f) {
return f.type() === type;
});
}
}, {
key: 'addField',
value: function addField(field) {
if (field.order() === null) {
field.order(this._fields.length, true);
}
this._fields.push(field);
this._fields = this._fields.sort(function (a, b) {
return a.order() - b.order();
});
return this;
}
return this;
}
}, {
key: 'order',
value: function order(_order) {
if (!arguments.length) return this._order;
this._order = _order;
return this;
}
}, {
key: 'getReferences',
value: function getReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getReferences(this._fields, withRemoteComplete);
}
}, {
key: 'getNonOptimizedReferences',
value: function getNonOptimizedReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getNonOptimizedReferences(this._fields, withRemoteComplete);
}
}, {
key: 'getOptimizedReferences',
value: function getOptimizedReferences(withRemoteComplete) {
return _UtilsReferenceExtractor2['default'].getOptimizedReferences(this._fields, withRemoteComplete);
}
}, {
key: 'getReferencedLists',
value: function getReferencedLists() {
return _UtilsReferenceExtractor2['default'].getReferencedLists(this._fields);
}
}, {
key: 'template',
value: function template(_template) {
if (!arguments.length) {
return this._template;
}
/*
* Supports various syntax
* fields([ Field1, Field2 ])
* fields(Field1, Field2)
* fields([Field1, {Field2, Field3}])
* fields(Field1, {Field2, Field3})
* fields({Field2, Field3})
*/
fields() {
if (!arguments.length) return this._fields;
this._template = _template;
[].slice.call(arguments).map(function(argument) {
View.flatten(argument).map(arg => this.addField(arg));
}, this);
return this;
}
hasFields() {
return this.fields.length > 0;
}
removeFields() {
this._fields = [];
return this;
}
getFields() {
return this._fields;
}
getField(fieldName) {
return this._fields.filter(f => f.name() === fieldName)[0];
}
getFieldsOfType(type) {
return this._fields.filter(f => f.type() === type);
}
addField(field) {
if (field.order() === null) {
field.order(this._fields.length, true);
return this;
}
this._fields.push(field);
this._fields = this._fields.sort((a, b) => (a.order() - b.order()));
}, {
key: 'identifier',
value: function identifier() {
return this.entity.identifier();
}
}, {
key: 'actions',
value: function actions(_actions) {
if (!arguments.length) return this._actions;
this._actions = _actions;
return this;
}
}, {
key: 'getErrorMessage',
value: function getErrorMessage(response) {
if (typeof this._errorMessage === 'function') {
return this._errorMessage(response);
}
return this;
}
static flatten(arg) {
if (arg.constructor.name === 'Object') {
console.warn('Passing literal of Field to fields method is deprecated use array instead');
let result = [];
for (let fieldName in arg) {
result = result.concat(View.flatten(arg[fieldName]));
}
return result;
return this._errorMessage;
}
if (Array.isArray(arg)) {
return arg.reduce(function(previous, current) {
return previous.concat(View.flatten(current))
}, []);
}, {
key: 'errorMessage',
value: function errorMessage(_errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = _errorMessage;
return this;
}
// arg is a scalar
return [arg];
}
}, {
key: 'url',
value: function url(_url) {
if (!arguments.length) return this._url;
this._url = _url;
return this;
}
}, {
key: 'getUrl',
value: function getUrl(identifierValue) {
if (typeof this._url === 'function') {
return this._url(identifierValue);
}
get type() {
return this._type;
}
return this._url;
}
}, {
key: 'validate',
value: function validate(entry) {
this._fields.map(function (field) {
var validation = field.validation();
order(order) {
if (!arguments.length) return this._order;
this._order = order;
return this;
}
if (typeof validation.validator === 'function') {
validation.validator(entry.values[field.name()], entry.values);
}
});
}
}, {
key: 'mapEntry',
getReferences(withRemoteComplete) {
return ReferenceExtractor.getReferences(this._fields, withRemoteComplete);
}
getNonOptimizedReferences(withRemoteComplete) {
return ReferenceExtractor.getNonOptimizedReferences(this._fields, withRemoteComplete);
}
getOptimizedReferences(withRemoteComplete) {
return ReferenceExtractor.getOptimizedReferences(this._fields, withRemoteComplete);
}
getReferencedLists() {
return ReferenceExtractor.getReferencedLists(this._fields);
}
template(template) {
if (!arguments.length) {
return this._template;
/**
* Map a JS object from the REST API Response to an Entry
*/
value: function mapEntry(restEntry) {
return _Entry2['default'].createFromRest(restEntry, this._fields, this.entity.name(), this.entity.identifier().name());
}
}, {
key: 'mapEntries',
value: function mapEntries(restEntries) {
return _Entry2['default'].createArrayFromRest(restEntries, this._fields, this.entity.name(), this.entity.identifier().name());
}
}, {
key: 'transformEntry',
this._template = template;
return this;
}
identifier() {
return this.entity.identifier();
}
actions(actions) {
if (!arguments.length) return this._actions;
this._actions = actions;
return this;
}
getErrorMessage(response) {
if (typeof(this._errorMessage) === 'function') {
return this._errorMessage(response);
/**
* Transform an Entry to a JS object for the REST API Request
*/
value: function transformEntry(entry) {
return entry.transformToRest(this._fields);
}
}, {
key: 'prepare',
return this._errorMessage;
}
errorMessage(errorMessage) {
if (!arguments.length) return this._errorMessage;
this._errorMessage = errorMessage;
return this;
}
url(url) {
if (!arguments.length) return this._url;
this._url = url;
return this;
}
getUrl(identifierValue) {
if (typeof(this._url) === 'function') {
return this._url(identifierValue);
/**
* Add a function to be executed before the view renders
*
* This is the ideal place to prefetch related entities and manipulate
* the dataStore.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - query: the query object (an object representation of the main request
* query string)
* - datastore: where the Entries are stored. The dataStore is accessible
* during rendering
* - view: the current View object
* - entry: the current Entry instance (except in listView)
* - Entry: the Entry constructor (required to transform an object from
* the REST response to an Entry)
* - window: the window object. If you need to fetch anything other than an
* entry and pass it to the view layer, it's the only way.
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.listView().prepare(['datastore', 'view', 'Entry', function(datastore, view, Entry) {
* const posts = datastore.getEntries(view.getEntity().uniqueId);
* const authorIds = posts.map(post => post.values.authorId).join(',');
* return fetch('http://myapi.com/authors?id[]=' + authorIds)
* .then(response => response.json())
* .then(authors => Entry.createArrayFromRest(
* authors,
* [new Field('first_name'), new Field('last_name')],
* 'author'
* ))
* .then(authorEntries => datastore.setEntries('authors', authorEntries));
* }]);
*/
value: function prepare(_prepare) {
if (!arguments.length) return this._prepare;
this._prepare = _prepare;
return this;
}
return this._url;
}
validate(entry) {
this._fields.map(function (field) {
let validation = field.validation();
if (typeof validation.validator === 'function') {
validation.validator(entry.values[field.name()], entry.values);
}, {
key: 'doPrepare',
value: function doPrepare() {
return this._prepare.apply(this, arguments);
}
}, {
key: 'enabled',
get: function () {
return this._enabled || !!this._fields.length;
}
}, {
key: 'type',
get: function () {
return this._type;
}
}], [{
key: 'flatten',
value: function flatten(arg) {
if (arg.constructor.name === 'Object') {
console.warn('Passing literal of Field to fields method is deprecated use array instead');
var result = [];
for (var fieldName in arg) {
result = result.concat(View.flatten(arg[fieldName]));
}
return result;
}
});
}
if (Array.isArray(arg)) {
return arg.reduce(function (previous, current) {
return previous.concat(View.flatten(current));
}, []);
}
// arg is a scalar
return [arg];
}
}]);
/**
* Map a JS object from the REST API Response to an Entry
*/
mapEntry(restEntry) {
return Entry.createFromRest(restEntry, this._fields, this.entity.name(), this.entity.identifier().name());
}
return View;
})();
mapEntries(restEntries) {
return Entry.createArrayFromRest(restEntries, this._fields, this.entity.name(), this.entity.identifier().name());
}
/**
* Transform an Entry to a JS object for the REST API Request
*/
transformEntry(entry) {
return entry.transformToRest(this._fields);
}
/**
* Add a function to be executed before the view renders
*
* This is the ideal place to prefetch related entities and manipulate
* the dataStore.
*
* The syntax depends on the framework calling the function.
*
* With ng-admin, the function can be an angular injectable, listing
* required dependencies in an array. Among other, the function can receive
* the following services:
* - query: the query object (an object representation of the main request
* query string)
* - datastore: where the Entries are stored. The dataStore is accessible
* during rendering
* - view: the current View object
* - entry: the current Entry instance (except in listView)
* - Entry: the Entry constructor (required to transform an object from
* the REST response to an Entry)
* - window: the window object. If you need to fetch anything other than an
* entry and pass it to the view layer, it's the only way.
*
* The function can be asynchronous, in which case it should return
* a Promise.
*
* @example
*
* post.listView().prepare(['datastore', 'view', 'Entry', function(datastore, view, Entry) {
* const posts = datastore.getEntries(view.getEntity().uniqueId);
* const authorIds = posts.map(post => post.values.authorId).join(',');
* return fetch('http://myapi.com/authors?id[]=' + authorIds)
* .then(response => response.json())
* .then(authors => Entry.createArrayFromRest(
* authors,
* [new Field('first_name'), new Field('last_name')],
* 'author'
* ))
* .then(authorEntries => datastore.setEntries('authors', authorEntries));
* }]);
*/
prepare(prepare) {
if (!arguments.length) return this._prepare;
this._prepare = prepare;
return this;
}
doPrepare() {
return this._prepare.apply(this, arguments);
}
}
export default View;
exports['default'] = View;
module.exports = exports['default'];
//# sourceMappingURL=View.js.map
{
"name": "admin-config",
"version": "0.12.0",
"version": "0.12.1",
"private": false,
"files": [
"*.md",
"lib"
],
"repository": {

@@ -19,4 +23,5 @@ "type": "git",

"scripts": {
"test": "make test"
"prepublish": "make transpile",
"test": "make test"
}
}

@@ -35,2 +35,16 @@ # admin-config [![Build Status](https://travis-ci.org/marmelab/admin-config.svg?branch=master)](https://travis-ci.org/marmelab/admin-config)

## Transpiling
In order to increase this library compatibility and to not force other users of this
library to use Babel, you need to transpile your ES6 code from `src/` to good old ES5
code (in `lib/`).
Just run:
``` sh
make transpile
```
And you are done!
## Running Tests

@@ -37,0 +51,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc