mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Add admin field application
This commit is contained in:

committed by
Romain Neutron

parent
7199d38ab3
commit
05dc3659af
@@ -1,11 +1,58 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'models/admin/field'
|
||||
'models/field'
|
||||
], function(_, Backbone, FieldModel) {
|
||||
var FieldCollection = Backbone.Collection.extend({
|
||||
initialize: function(models, options) {
|
||||
if (!"sbas_id" in options) {
|
||||
throw "You must specify a sbasId option when creating a new field model"
|
||||
}
|
||||
this.sbasId = options.sbas_id;
|
||||
},
|
||||
model: FieldModel,
|
||||
url: '/admin/fields/1/fields'
|
||||
url: function() {
|
||||
return '/admin/fields/' + this.sbasId + '/fields';
|
||||
},
|
||||
search: function(letters) {
|
||||
if (letters === "")
|
||||
return this;
|
||||
|
||||
var pattern = new RegExp(letters, "gi");
|
||||
|
||||
return _(this.filter(function(data) {
|
||||
return pattern.test(data.get("name"));
|
||||
}));
|
||||
},
|
||||
comparator: function(item) {
|
||||
return item.get("sorter");
|
||||
},
|
||||
nextIndex: function(model) {
|
||||
var index = this.indexOf(model);
|
||||
|
||||
if (index < 0) {
|
||||
throw "Model not found"
|
||||
}
|
||||
|
||||
if ((index + 1) === this.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return index + 1;
|
||||
},
|
||||
previousIndex: function(model) {
|
||||
var index = this.indexOf(model);
|
||||
|
||||
if (index < 0) {
|
||||
throw "Model not found"
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return index - 1;
|
||||
}
|
||||
});
|
||||
|
||||
return FieldCollection;
|
||||
|
Reference in New Issue
Block a user