operating_systems.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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() {
  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. /**
  33. * shows OS in different way depending on amount
  34. * @type {String}
  35. */
  36. osText: function() {
  37. switch (this.get('content.operatingSystems.length')) {
  38. case 0:
  39. return Em.I18n.t("none").toCapital();
  40. break;
  41. case 1:
  42. return this.get('content.operatingSystems').getEach('osType');
  43. break;
  44. default :
  45. return this.get('content.operatingSystems.length') + " " + Em.I18n.t("common.oss");
  46. }
  47. }.property('content.operatingSystems.length'),
  48. labels: function() {
  49. return this.get('content.operatingSystems') &&
  50. this.get('content.operatingSystems').getEach('osType').join("<br/>");
  51. }.property('content.operatingSystems.length')
  52. });