UNPKG

zettapi_client

Version:

Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project

64 lines (54 loc) 1.77 kB
var app = angular.module('zapi', [ 'ngSanitize', 'ngAnimate', 'ui.bootstrap', 'blockUI', 'inform', 'chart.js', 'btford.socket-io', 'ngCsv', 'ngTable', 'selector', 'angularUtils.directives.dirPagination', 'angularMoment', 'ngIdle', 'pascalprecht.translate' ]).config(function (TitleProvider) { TitleProvider.enabled(false); }).provider('zapi', function (apiEntityMap) { var map = {}; var idle = false; return { getRoutes: function (param) { if (typeof map[param.entity] === 'undefined') return 'client/entity/entity.notfound.html'; if (typeof map[param.entity][param.action] === 'undefined') return 'client/entity/entity.notfound.html'; switch (param.action) { case 'edit': return 'client/entity/entity.edit.html'; case 'view': if (typeof param.id === 'undefined') return 'client/entity/entity.notfound.html'; return 'client/entity/entity.view.html'; case 'list': if (typeof param.id !== 'undefined') return 'client/entity/entity.notfound.html'; return 'client/entity/entity.list.html'; default: return 'client/entity/entity.notfound.html'; } }, setMap: function (entityMap) { map = apiEntityMap; for (var key in entityMap) { map[key] = entityMap[key]; } }, setIdle: function (state) { idle = state; }, $get: function () { return { entityMap: map, idle: idle }; } }; });