cmzone-view-model.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. (function() {
  2. BemsWebApplication.CmZoneViewModel = function(data) {
  3. this.SiteId = ko.observable();
  4. this.BuildingId = ko.observable();
  5. this.FloorId = ko.observable();
  6. this.ZoneId = ko.observable();
  7. this.Name = ko.observable();
  8. this.Target_temperature = ko.observable();
  9. this.Target_humidity = ko.observable();
  10. if(data)
  11. this.fromJS(data);
  12. };
  13. $.extend(BemsWebApplication.CmZoneViewModel.prototype, {
  14. toJS: function() {
  15. return {
  16. SiteId: this.SiteId(),
  17. BuildingId: this.BuildingId(),
  18. FloorId: this.FloorId(),
  19. ZoneId: this.ZoneId(),
  20. Name: this.Name(),
  21. Target_temperature: this.Target_temperature(),
  22. Target_humidity: this.Target_humidity(),
  23. };
  24. },
  25. fromJS: function(data) {
  26. if(data) {
  27. this.SiteId(data.SiteId);
  28. this.BuildingId(data.BuildingId);
  29. this.FloorId(data.FloorId);
  30. this.ZoneId(data.ZoneId);
  31. this.Name(data.Name);
  32. this.Target_temperature(data.Target_temperature);
  33. this.Target_humidity(data.Target_humidity);
  34. }
  35. }
  36. });
  37. })();