operating_systems.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /** Licensed to the Apache Software Foundation (ASF) under one
  2. * or more contributor license agreements. See the NOTICE file
  3. * distributed with this work for additional information
  4. * regarding copyright ownership. The ASF licenses this file
  5. * to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance
  7. * with the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. var App = require('app');
  18. App.OperatingSystemsView = Em.View.extend({
  19. templateName: require('templates/main/admin/stack_versions/os_for_repo_versions'),
  20. didInsertElement: function () {
  21. this.set('isOsCollapsed', true);
  22. },
  23. toggleOs: function(event) {
  24. if (this.get('hasMoreOs')) {
  25. this.set('isOsCollapsed', !this.get('isOsCollapsed'));
  26. this.$('.operating-systems').toggle();
  27. }
  28. },
  29. hasMoreOs: function() {
  30. return this.get('content.operatingSystems.length') > 1;
  31. }.property('content.operatingSystems.length'),
  32. osText: function() {
  33. switch (this.get('content.operatingSystems.length')) {
  34. case 0:
  35. return Em.I18n.t("none");
  36. break;
  37. case 1:
  38. return this.get('content.operatingSystems').getEach('osType');
  39. break;
  40. default :
  41. return this.get('content.operatingSystems.length') + Em.I18n.t("common.oss");
  42. }
  43. }.property('content.operatingSystems.length'),
  44. labels: function() {
  45. return this.get('content.operatingSystems') &&
  46. this.get('content.operatingSystems').getEach('osType').join("<br/>");
  47. }.property('content.operatingSystems.length')
  48. });