12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /**
- * Created by robin on 12/12/16.
- */
-
- (function () {
- 'use strict';
-
- angular.module('appSdk')
- .factory('articlesDataAccess', ['luWebApiCrudDataAccess', 'luDataInitializer',
- function (luWebApiCrudDataAccess, luDataInitializer) {
-
- var DataAccess = luWebApiCrudDataAccess.create('/api/articles');
-
- DataAccess.defaultDbo = {
- id: null,
- title: null,
- type: null,
- text: null,
- pictureUrl: null,
- pictureCaption: null,
- fields: [],
- createdAt: null,
- updatedAt: null,
- _itemType: 'articles',
- toString: function () {
- return this.id;
- }
- };
-
- DataAccess.defaultFieldDbo = {
- value: null,
- property: null,
- type: 20.0
- };
-
- DataAccess.initFieldDbo = function (dbo, type) {
- if (dbo == null) {
- return null;
- }
- var dboInit = DataAccess.extendDeep({}, DataAccess.defaultFieldDbo, dbo);
- return dboInit;
- };
-
- DataAccess.initFieldModel = function (model, op) {
- if (model == null) {
- return null;
- }
- var modelInit = angular.copy(model);
- return modelInit;
- };
-
- DataAccess.articleFieldModelInitializer = luDataInitializer.create(DataAccess.initFieldModel);
-
- DataAccess.articleFieldDboInitializer = luDataInitializer.create(DataAccess.initFieldDbo);
-
- DataAccess.initDbo = function (dbo, type) {
- if (dbo == null) {
- return null;
- }
- var dboInit = DataAccess._initDbo(dbo);
- dboInit.fields = DataAccess.articleFieldDboInitializer.initListData(dboInit.fields, type);
- dboInit.title = dboInit.id;
- return dboInit;
- };
-
- DataAccess.initModel = function (model, op) {
- if (model == null) {
- return null;
- }
- var modelInit = DataAccess._initModel(model, op);
- modelInit.fields = DataAccess.articleFieldModelInitializer.initListData(modelInit.fields, op);
- modelInit.id = modelInit.title;
- delete modelInit.title;
- return modelInit;
- };
-
- return DataAccess;
- }]);
- })();
|