repo_version_view.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. var filters = require('views/common/filter_view');
  19. var sort = require('views/common/sort_view');
  20. App.RepoVersionsView = App.TableView.extend({
  21. templateName: require('templates/main/admin/stack_versions/repo_versions'),
  22. content: function () {
  23. return this.get('controller.content');
  24. }.property('controller.content'),
  25. /**
  26. * return filtered number of all content number information displayed on the page footer bar
  27. * @returns {String}
  28. */
  29. filteredContentInfo: function () {
  30. return this.t('tableView.filters.filteredConfigVersionInfo').format(this.get('filteredCount'), this.get('content.length'));
  31. }.property('filteredCount', 'content.length'),
  32. /**
  33. * associations between stack version property and column index
  34. * @type {Array}
  35. */
  36. colPropAssoc: function () {
  37. var associations = [];
  38. associations[1] = 'repositoryVersion';
  39. associations[2] = 'displayName';
  40. associations[3] = 'operatingSystems';
  41. return associations;
  42. }.property(),
  43. sortView: sort.wrapperView,
  44. repoNameSort: sort.fieldView.extend({
  45. column: 1,
  46. name: 'repositoryVersion',
  47. displayName: Em.I18n.t('admin.stackVersions.table.header.stack'),
  48. type: 'version',
  49. classNames: ['first']
  50. }),
  51. repoVersionSort: sort.fieldView.extend({
  52. column: 2,
  53. name: 'displayName',
  54. displayName: Em.I18n.t('admin.stackVersions.table.header.version'),
  55. type: 'version'
  56. }),
  57. osSort: sort.fieldView.extend({
  58. column: 3,
  59. name: 'operatingSystems.length',
  60. displayName: Em.I18n.t('admin.stackVersions.table.header.os'),
  61. type: 'number'
  62. }),
  63. repoNameFilterView: filters.createSelectView({
  64. column: 1,
  65. fieldType: 'filter-input-width',
  66. content: function () {
  67. var names = this.get('parentView.content').mapProperty('repositoryVersion').uniq();
  68. return [
  69. {
  70. value: '',
  71. label: Em.I18n.t('common.all')
  72. }
  73. ].concat(names.map(function (name) {
  74. return {
  75. value: name,
  76. label: name
  77. }
  78. }));
  79. }.property('App.router.repoVersionsController.dataIsLoaded'),
  80. onChangeValue: function () {
  81. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
  82. }
  83. }),
  84. repoVersionFilterView: filters.createTextView({
  85. column: 2,
  86. fieldType: 'filter-input-width',
  87. onChangeValue: function () {
  88. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
  89. }
  90. }),
  91. osFilterView: filters.createSelectView({
  92. column: 3,
  93. fieldType: 'filter-input-width',
  94. content: function () {
  95. var names = App.OS.find().mapProperty('osType').uniq();
  96. return [
  97. {
  98. value: '',
  99. label: Em.I18n.t('common.all')
  100. }
  101. ].concat(names.map(function (name) {
  102. return {
  103. value: name,
  104. label: name
  105. }
  106. }));
  107. }.property('App.router.mainStackVersionsController.dataIsLoaded'),
  108. onChangeValue: function () {
  109. this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'os');
  110. }
  111. }),
  112. didInsertElement: function() {
  113. this.get('controller').load();
  114. },
  115. RepositoryVersionView: Em.View.extend({
  116. tagName: 'tr',
  117. didInsertElement: function () {
  118. App.tooltip(this.$("[rel='Tooltip']"));
  119. }
  120. })
  121. });