PATH:
usr
/
local
/
jetapps
/
frontend
/
jetbackup
/
app
/
services
'use strict'; define([ 'app', ], function (app) { app.factory('meta', ['storage', "lang", function(storage, lang) { var meta = function(storage_id) { if(storage_id === undefined) throw Error("No storage name provided"); this._storage = storage.create("sort_" + storage_id); for(var i in this._defaults) { if(!this._storage.isSet(i) && this._defaults[i] !== undefined) { this.set(i, this._defaults[i]); } } }; meta.prototype = { _defaults: { sortReverse: false, sortBy: '', sortDirection: '', sortFields: [], filterValue: '', maxPages: 3, totalItems: 0, currentPage: 1, pageSize: 15, pageSizes: [15, 25, 50], start: 0, limit: 15, itemCountText: undefined }, _storage: undefined, _storage_key: undefined, _show_count_text: false, set: function (key, value) { this._storage.set(key, value); this._storage.save(); }, get: function (key, defaultValue) { return this._storage.get(key, defaultValue); }, setSortReverse: function (sortReverse) { this.set('sortReverse', sortReverse); }, getSortReverse: function () { return this.get('sortReverse'); }, setSortBy: function (sortBy) { this.set('sortBy', sortBy); }, getSortBy: function () { return this.get('sortBy'); }, setSortDirection: function (sortDirection) { this.set('sortDirection', sortDirection); }, getSortDirection: function () { return this.get('sortDirection'); }, getSortDirectionInt: function() { return this.getSortDirection() === "asc" ? 1 : -1; }, setSortFields: function (sortFields) { this.set('sortFields', sortFields); }, getSortFields: function () { return this.get('sortFields'); }, setFilter: function (filter) { this.set('filterValue', filter); }, getFilter: function () { return this.get('filterValue'); }, setMaxPages: function (maxPages) { this.set('maxPages', maxPages); }, getMaxPages: function () { return this.get('maxPages'); }, setTotalItems: function (totalItems) { this.set('totalItems', totalItems); }, getTotalItems: function () { return this.get('totalItems'); }, setCurrentPage: function (currentPage) { this.set('currentPage', currentPage); }, getCurrentPage: function () { return this.get('currentPage'); }, setPageSize: function (pageSize) { this.set('pageSize', pageSize); }, getPageSize: function () { return this.get('pageSize'); }, setPageSizes: function (pageSizes) { this.set('pageSizes', pageSizes); }, getPageSizes: function () { return this.get('pageSizes'); }, setStart: function (start) { this.set('start', start); }, getStart: function () { return this.get('start'); }, setLimit: function (limit) { this.set('limit', limit); }, getLimit: function () { return this.get('limit'); }, setItemCountText: function (text) { this.set('itemCountText', text); }, getItemCountText: function () { return this.get('itemCountText'); }, showItemCountText: function () { this._show_count_text = true; return this._show_count_text; }, getSkip: function () { return (this.getCurrentPage() - 1) * this.getPageSize(); }, showPagination: function () { return this.get('showPagination', false); }, setData: function (data) { this._storage.setData(data); }, getData: function () { return this._storage.getData(); }, calculate: function (data) { if(data === undefined) data = []; if (this.getTotalItems() > this._min(this.getPageSizes())) { this.set('showPagination', true); var start = (this.getCurrentPage() - 1) * this.getPageSize(); this.setStart(start + 1); //this.setLimit(start + data.length); } else { // hide pager and pagination this.set('showPagination', false); this.setStart((data.length === 0) ? 0 : 1); this.setLimit(data.length); } this.setItemCountText(lang.t("%s - %s of %s records", this.getStart(), this.getPageSize() * this.getCurrentPage() > this.getTotalItems() ? this.getTotalItems() : this.getPageSize() * this.getCurrentPage(), this.getTotalItems() )); }, _min: function (ary) { var min = null; for(var i; i < ary.length; i++) if(min === null || ary[i] < min) min = ary[i]; return min === null ? 0 : min; } }; return { new: function (storage_id) { return new meta(storage_id); } }; }]); });
[-] utils.js
[edit]
[+]
..
[-] lang.js
[edit]
[-] jetapi.js
[edit]
[-] consts.js
[edit]
[-] storage.js
[edit]
[-] meta.js
[edit]
[-] backup.js
[edit]