without: '<%= message('quality_gates.projects.without') -%>',
all: '<%= message('quality_gates.projects.all') -%>',
select_hint: '<%= message('quality_gates.projects.select_hint') -%>',
- deselect_hint: '<%= message('quality_gates.projects.deselect_hint') -%>'
+ deselect_hint: '<%= message('quality_gates.projects.deselect_hint') -%>',
+ noResults: '<%= message('quality_gates.projects.noResults') -%>'
}
}
};
}
},
- toggle: function () {
+ toggle: function (e) {
+ if (this.settings.readOnly) {
+ $(e.target).prop('checked', !$(e.target).prop('checked'));
+ return;
+ }
+
var selected = this.model.get('selected'),
that = this,
url = selected ? this.settings.deselectUrl : this.settings.selectUrl,
this.$el.html(this.template(this.settings.labels))
.width(this.settings.width);
- this.$listContainer = this.$('.select-list-list-container')
- .height(this.settings.height)
- .css('overflow', 'auto')
- .on('scroll', function () {
- that.scroll();
- });
+ this.$listContainer = this.$('.select-list-list-container');
+ if (!this.settings.readOnly) {
+ this.$listContainer
+ .height(this.settings.height)
+ .css('overflow', 'auto')
+ .on('scroll', function () {
+ that.scroll();
+ });
+ } else {
+ this.$listContainer.addClass('select-list-list-container-readonly');
+ }
this.$list = this.$('.select-list-list');
.addClass('error').text(that.settings.errorMessage)
.insertBefore(that.$el);
};
+
+ if (this.settings.readOnly) {
+ this.$('.select-list-control').remove();
+ }
},
renderList: function () {
view.remove();
});
this.listItemViews = [];
- this.collection.each(this.renderListItem, this);
+ if (this.collection.length > 0) {
+ this.collection.each(this.renderListItem, this);
+ } else {
+ this.renderEmpty();
+ }
this.$listContainer.scrollTop(0);
},
itemView.render();
},
+ renderEmpty: function () {
+ this.$listContainer.html(this.settings.labels.noResults);
+ },
+
confirmFilter: function (model) {
if (this.currentFilter !== 'all') {
this.collection.remove(model);
width: '50%',
height: 400,
+ readOnly: false,
+
format: function (item) {
return item.value;
},
labels: {
selected: 'Selected',
deselected: 'Deselected',
- all: 'All'
+ all: 'All',
+ noResults: ''
},
tooltips: {
new SelectList
el: @$('#select-list-projects')
width: '100%'
+ readOnly: true
format: (item) -> item.name
searchUrl: "#{baseUrl}/api/qualitygates/search?gateId=#{@options.gateId}"
selectUrl: "#{baseUrl}/api/qualitygates/select"
selected: window.SS.phrases.projects.with
deselected: window.SS.phrases.projects.without
all: window.SS.phrases.projects.all
+ noResults: window.SS.phrases.projects.noResults
tooltips:
select: window.SS.phrases.projects.select_hint
deselect: window.SS.phrases.projects.deselect_hint
+
+
serializeData: ->
_.extend super, canEdit: @options.app.canEdit
return new SelectList({
el: this.$('#select-list-projects'),
width: '100%',
+ readOnly: true,
format: function(item) {
return item.name;
},
labels: {
selected: window.SS.phrases.projects["with"],
deselected: window.SS.phrases.projects.without,
- all: window.SS.phrases.projects.all
+ all: window.SS.phrases.projects.all,
+ noResults: window.SS.phrases.projects.noResults
},
tooltips: {
select: window.SS.phrases.projects.select_hint,