UNPKG

zettapi_client

Version:

Admin panel and client-side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project.

172 lines (169 loc) 4.92 kB
app.constant('chartTypes', [ ['bar', 'doughnut', 'pie', 'horizontalBar'], ['line', 'radar'], ['bubble', 'polar-area'] ]); app.constant('graphOptions', { responsive: true, responsiveAnimationDuration: 1500, tooltip: { enabled: true }, elements: { line: { tension: 0.4, stepped: false } } }); app.constant('apiEntityMap', { activity: { key: "activity", title: "api.pages.activity.title", list: { admin: false } }, alert: { key: "alert", title: "api.pages.alert.title", list: { admin: true }, edit: { admin: true }, modal: true }, country: { key: "country", title: "api.pages.country.title", list: { admin: true } }, document: { //todo key: "document", title: "api.pages.document.title", list: { admin: true } }, error: { key: "error", title: "api.pages.error.title", list: { admin: true } }, holiday: { key: "holiday", title: "api.pages.holiday.title", lookup: ['country'], list: { admin: true }, edit: { admin: true }, modal: true, beforeSave: function (item, callback) { if (!item.name) return callback("Introduza um nome do feriado"); if (!item.date && !item.formula) return callback("Impossivel calcular próxima ocorrência para este feriado"); if (item.date) { var pattern = /^(?:(?:[12][0-9]|0[1-9])\/(02)|(?:30|[12][0-9]|0[1-9])\/(?:(?:0[469]|11))|(?:3[01]|[12][0-9]|0[1-9])\/(?:(?:0[13578]|1[02])))$/; if (!pattern.test(item.date)) return callback("A data deve ser no formato dd/mm"); } else if (item.formula) { try { var currentYear = new Date().getFullYear(); eval('my_function = ' + item.formula); var d = my_function(currentYear); if (Object.prototype.toString.call(d) !== "[object Date]") return callback("Data inválida"); //it is a date if (isNaN(d.getTime())) return callback("Data inválida"); } catch (e) { return callback("A formula que introduziu contém um erro: " + e); } } callback(); } }, license: { key: "license", title: "api.pages.license.title", lookup: ['module'], list: { admin: false }, edit: { admin: true }, view: { admin: false }, modal: true }, maintenance: { key: "maintenance", title: "api.pages.maintenance.title", list: { admin: true }, edit: { admin: true }, modal: true }, message: { key: "message", title: "api.pages.message.title", list: { admin: false } }, module: { key: "module", title: "api.pages.module.title", list: { admin: false }, edit: { admin: true }, modal: true, blank: function () { return { price: [] }; } }, newsletter: { //todo key: "newsletter", title: "api.pages.newsletter.title", list: { admin: true } }, report: { key: "report" }, role: { key: "role", title: "api.pages.role.title", list: { admin: true }, edit: { admin: true }, modal: true }, run: { //todo key: "run", title: "api.pages.run.title", list: { admin: true } }, slider: { key: "slider", title: "api.pages.slider.title", list: { admin: true }, edit: { admin: true } }, support: { //todo key: "support", title: "api.pages.support.title", list: { admin: true }, modal: true }, task: { key: "task", title: "api.pages.task.title", list: { admin: true }, edit: { admin: true }, modal: true, beforeSave: function (item, callback) { if (!item.name) return callback("Indique um nome para a tarefa"); if (item.name.trim() === "") return callback("Indique um nome para a tarefa"); if (!item.type) return callback("Escolha um tipo de tarefa"); if (!item.criteria) return callback("Complete o critério de periodicidade"); if (!item.criteria.month) return callback("Complete o critério de periodicidade"); if (!item.criteria.monthday) return callback("Complete o critério de periodicidade"); if (!item.criteria.weekday) return callback("Complete o critério de periodicidade"); if (!item.criteria.hour) return callback("Complete o critério de periodicidade"); if (!item.criteria.minute) return callback("Complete o critério de periodicidade"); callback(); } }, user: { key: "user", title: "api.pages.user.title", lookup: ['role', 'country'], list: { admin: false }, edit: { clearance: 1 }, modal: true, beforeSave: function (item, callback) { if (!item.username) return callback("Introduza um username"); if (item.username.trim() === "") return callback("Introduza um username"); if (!item.email) return callback("Introduza um email"); if (item.email.trim() === "") return callback("Introduza um email"); callback(); } } });