VEntityList.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. define([ "require", "utils/Globals", "collection/BaseCollection", "models/VEntity", "utils/UrlLinks" ], function(require, Globals, BaseCollection, VEntity, UrlLinks) {
  2. "use strict";
  3. var VEntityList = BaseCollection.extend({
  4. url: UrlLinks.entitiesApiUrl(),
  5. model: VEntity,
  6. initialize: function() {
  7. this.modelName = "VEntity", this.modelAttrName = "entityDefs";
  8. },
  9. parseRecords: function(resp, options) {
  10. try {
  11. if (resp.entity && resp.referredEntities) {
  12. var obj = {
  13. entity: resp.entity,
  14. referredEntities: resp.referredEntities
  15. };
  16. return obj;
  17. }
  18. return resp[this.modelAttrName] ? resp[this.modelAttrName] : resp;
  19. } catch (e) {
  20. console.log(e);
  21. }
  22. },
  23. getAdminData: function(options) {
  24. var url = UrlLinks.adminApiUrl();
  25. return options = _.extend({
  26. contentType: "application/json",
  27. dataType: "json"
  28. }, options), this.constructor.nonCrudOperation.call(this, url, "POST", options);
  29. }
  30. }, {
  31. tableCols: {}
  32. });
  33. return VEntityList;
  34. });