159:2bc0a5ac4959
Anton Shestakov <av6@dwimlabs.net>, 2017-10-31
provision: WSGI is an acronym

previous change 148:7a236aa969f8

static/js/framework/views/projects.js

Permissions: -rw-r--r--

Other formats: Feeds:
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
var ProjectsView = CollectionViewWithInlineEditor.extend({
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
initialize: function(options) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.tasks = options.tasks;
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.rawTemplates = options.templates;
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.compileTemplates(options.templates);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.bindCollection();
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
options.controls.create.click(function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
options.collection.create({
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
name: 'new project'
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
}, {wait: true});
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
},
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
clear: function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.$el.empty();
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
},
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
renderItem: function(project) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
var $item = $(this.templates.project(project.toJSON()));
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
$item.tasksView = new TasksView({
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
el: $item.find('.tasks'),
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
collection: project.tasks,
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
templates: this.rawTemplates,
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
controls: {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
create: $item.find('.btn-new-task')
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
}
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
$item
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
.find('.progress')
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
.click(function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
var $progress = $(this);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
$progress.addClass('active');
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.switchColor().then(function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
$progress.removeClass('active');
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
$item
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
.find('.btn-delete-project')
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
.click(function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.destroy({wait: true});
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
return $item;
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
},
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
updateProgress: function(project) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.$item
61
61:ecb8269aa17f update to Bootstrap 3
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:2c9942109f13
line | diff
.find('.progress-bar')
61:ecb8269aa17f update to Bootstrap 3
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:2c9942109f13
line | diff
.removeClass('progress-bar-info progress-bar-success progress-bar-warning progress-bar-danger')
61:ecb8269aa17f update to Bootstrap 3
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:2c9942109f13
line | diff
.addClass(project.get('color') ? 'progress-bar-' + project.get('color') : '')
61:ecb8269aa17f update to Bootstrap 3
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:2c9942109f13
line | diff
.attr('aria-valuenow', (100 * project.tasks.progress()))
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
.css('width', (100 * project.tasks.progress()) + '%');
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
},
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
appendItem: function(project) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
var tasks = this.tasks;
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.tasks = new Backbone.Shard({
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
collection: this.tasks,
7
7:5c5d433b3a14 Moving toward a multi-workspace work model. There's no auth, knowing workspace id gives full access.
Anton Shestakov <engored@ya.ru>
previous changes: 0:a02e94c5b96b
line | diff
filter: function(task) { return task.get('project_id') === project.id; }
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.tasks.progress = function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
return this.filter(function(task) { return task.get('done') === true; }).length / this.size();
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
};
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.tasks.create = function(attributes, options) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
attributes = attributes || {};
61
61:ecb8269aa17f update to Bootstrap 3
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:2c9942109f13
line | diff
attributes.project_id = project.id;
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
return tasks.create(attributes, options);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
};
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.$item = this.renderItem(project);
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.bindInlineEditable(project, '.inline-editable[data-model="project"]');
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.updateProgress(project);
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.on('change:name', function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.$item.find('[data-model="project"][data-model-attribute="name"]').text(project.get('name'));
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.on('change:color', function() {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.updateProgress(project);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
}, this);
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
12
12:2c9942109f13 Update project progress on tasks reset, of course.
Anton Shestakov <engored@ya.ru>
previous changes: 7:5c5d433b3a14
line | diff
project.tasks.on('add remove change:done reset', function() {
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.updateProgress(project);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
}, this);
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
this.$el.append(project.$item);
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
},
148
148:7a236aa969f8 js: remove trailing spaces
Anton Shestakov <av6@dwimlabs.net>
previous changes: 61:ecb8269aa17f
line | diff
0
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
removeItem: function(project) {
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
project.$item.remove();
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
}
0:a02e94c5b96b Made public.
Anton Shestakov <engored@ya.ru>
previous changes:
line | diff
});