user.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.UserModel = Em.Object.extend({
  20. userName:null,
  21. id:0
  22. });
  23. App.User = DS.Model.extend({
  24. userName:DS.attr('string'),
  25. admin:DS.attr('boolean'),
  26. password:DS.attr('string'),
  27. auditItems:DS.hasMany('App.ServiceAudit')
  28. });
  29. App.UserForm = App.Form.extend({
  30. className:App.User,
  31. fieldsOptions:[
  32. { name:"userName", displayName:"Username" },
  33. { name:"password", displayName:"Password", displayType:"password", disableRequiredOnExistent:true },
  34. { name:"passwordRetype", displayName:"Retype Password", displayType:"passwordRetype", disableRequiredOnExistent:true },
  35. { name:"admin", displayName:"Admin", displayType:"checkbox", isRequired:false }
  36. ],
  37. fields:[],
  38. disableUsername:function () {
  39. var field = this.getField("userName");
  40. if (field) field.set("disabled", this.get('isObjectNew') ? false : "disabled");
  41. }.observes('isObjectNew')
  42. });
  43. App.User.FIXTURES = [
  44. {
  45. id:1,
  46. user_name:'admin',
  47. password: 'admin',
  48. admin:1
  49. },
  50. {
  51. id:2,
  52. user_name:'vrossi',
  53. admin:1
  54. },
  55. {
  56. id:3,
  57. user_name:'casey.stoner',
  58. admin:0
  59. },
  60. {
  61. id:4,
  62. user_name:'danip',
  63. admin:0
  64. }
  65. ];