mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Add field application
Add asset dependencies Add field model Add field tests Add field app Add JS build Add end file blank line Adjust asset dependencies version Remove assets test libraries from build Remove unecessary comments Add end file blank line Fix indent
This commit is contained in:

committed by
Romain Neutron

parent
d0431248ce
commit
1ff4e4060b
59
www/scripts/apps/admin/fields/router.js
Normal file
59
www/scripts/apps/admin/fields/router.js
Normal file
@@ -0,0 +1,59 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'models/admin/field',
|
||||
'apps/admin/fields/views/edit',
|
||||
'apps/admin/fields/views/list',
|
||||
'apps/admin/fields/collections/fields'
|
||||
], function($, _, Backbone, FieldModel, FieldEditView, FieldListView, FieldsCollection) {
|
||||
var AppRouter = Backbone.Router.extend({
|
||||
routes: {
|
||||
'field/:id': "getField",
|
||||
'fields': 'showFields',
|
||||
'*actions': 'defaultAction'
|
||||
}
|
||||
});
|
||||
|
||||
var initialize = function() {
|
||||
var app_router = new AppRouter();
|
||||
|
||||
app_router.on('route:getField', function (id) {
|
||||
var field = new FieldModel({id: id});
|
||||
|
||||
field.fetch().done(function() {
|
||||
var fieldEditView = new FieldEditView({
|
||||
el: $('.right-block')[0],
|
||||
model: field
|
||||
});
|
||||
|
||||
fieldEditView.render();
|
||||
});
|
||||
});
|
||||
|
||||
app_router.on('route:showFields', function() {
|
||||
var fieldsCollection = new FieldsCollection();
|
||||
fieldsCollection.fetch().done(function() {
|
||||
var fieldListView = new FieldListView({
|
||||
collection: fieldsCollection,
|
||||
el: $('ul#collection-fields')[0]
|
||||
});
|
||||
|
||||
fieldListView.render();
|
||||
});
|
||||
});
|
||||
|
||||
app_router.on('route:defaultAction', function(actions) {
|
||||
console.log('No route:', actions);
|
||||
});
|
||||
|
||||
Backbone.history.start();
|
||||
|
||||
// Show fields on start up
|
||||
app_router.navigate('fields', { trigger: true });
|
||||
};
|
||||
|
||||
return {
|
||||
initialize: initialize
|
||||
};
|
||||
});
|
Reference in New Issue
Block a user