Skip to content

Commit

Permalink
Merge branch 'integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrsavitski committed Apr 4, 2016
2 parents 4538256 + 1fbf8e1 commit fa370f4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
4 changes: 3 additions & 1 deletion js/data/episode/UserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ define(['config/config', 'logger', 'voc', 'underscore', 'jquery', 'data/Data', '
this.vie.load({
'service' : 'learnEpVersionCurrentGet'
}).from('sss').execute().success(function(version) {
user.set(Voc.currentVersion, version.id);
if ( version && version.id ) {
user.set(Voc.currentVersion, version.id);
}
});
};
/**
Expand Down
2 changes: 1 addition & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var require = (function() {
var appVersion = '4.3.0';
var appVersion = '4.3.1';
return {
config: {
'config/config': {
Expand Down
9 changes: 9 additions & 0 deletions js/view/WidgetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ define(['config/config', 'logger', 'backbone', 'jquery', 'voc', 'underscore', 'j
this.LOG.debug('el', this.el, this.$el);
this.listenTo(this.model, 'destroy', this.remove);

var that = this;
if ( this.model.isof(Voc.ORGANIZE) ) {
var version = this.model.get(Voc.belongsToVersion);

version.on('destroy', function() {
that.model.destroy();
});
}

this.circleRenameModalView = this.options.circleRenameModalView;

},
Expand Down
7 changes: 5 additions & 2 deletions js/view/episode/EpisodeManagerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define(['config/config', 'vie', 'logger', 'tracker', 'underscore', 'jquery', 'ba
initialize: function() {
var that = this;
this.heightChangeAllowed = true;
this.episodeDeletionInProgress = false;
this.views = {};
this.LOG.debug('options', this.options);
this.vie = this.options.vie;
Expand Down Expand Up @@ -246,25 +247,27 @@ define(['config/config', 'vie', 'logger', 'tracker', 'underscore', 'jquery', 'ba
a = that.model.vie.entities.get(a);
that.addEpisode(a);
});
that.redrawEpisodes();

var deleted = _.difference(previous, set);
this.LOG.debug('deleted', deleted);
_.each(deleted, function(a){
a = that.model.vie.entities.get(a);
that.removeEpisode(a);
});

that.redrawEpisodes();
},
addEpisode: function(model) {
this.LOG.debug('addEpisode', model);
var view = new EpisodeView({'model':model});
var view = new EpisodeView({ 'model': model, episodeManager: this });
this.$el.find('ul.dropdown-menu').append(view.render().$el);
this.views[model.cid] = view;
if ( model === this.currentEpisode ) { view.highlight();}
return this;
},
removeEpisode: function(model) {
this.LOG.debug('removeEpisode', model);
delete this.views[model.cid];
},
createBlank: function(e) {
var that = this;
Expand Down
20 changes: 19 additions & 1 deletion js/view/episode/EpisodeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ define(['vie', 'logger', 'underscore', 'jquery', 'backbone', 'voc','data/episode
e.preventDefault();
e.stopPropagation();

if ( this.options.episodeManager && this.options.episodeManager.episodeDeletionInProgress ) {
SystemMessages.addWarningMessage('Episode is being deleted, please wait until the process has finished!');
return;
}

var confirmDelete = confirm('Disconnect yourself from the Episode. The Episode will just disappear from your workspace and the other contributors will be able to go on collaborating on it.');

if ( true === confirmDelete ) {

var that = this,
promise = EpisodeData.removeEpisode(this.model);
promise = EpisodeData.removeEpisode(this.model),
elementContainer = this.$el.parent().parent();

this._disableEpisodeDeletion(elementContainer);

promise.done(function(response) {
var episode = that.model,
Expand Down Expand Up @@ -93,14 +101,24 @@ define(['vie', 'logger', 'underscore', 'jquery', 'backbone', 'voc','data/episode
version.destroy();

SystemMessages.addSuccessMessage('Episode <strong>' + episodeLabel + '</strong> successfully removed.');
that._enableEpisodeDeletion(elementContainer);
}).fail(function(f) {
SystemMessages.addDangerMessage('Error! Could not delete episode <strong>' + that.model.get(Voc.label) + '</strong>.');
that._enableEpisodeDeletion(elementContainer);
});

}
},
__getCurrentUserEntity: function() {
return this.model.collection.get(UserParams.user);
},
_disableEpisodeDeletion: function(elementContainer) {
this.options.episodeManager.episodeDeletionInProgress = true;
elementContainer.find('button.deleteEpisode').prop('disabled', true);
},
_enableEpisodeDeletion: function(elementContainer) {
this.options.episodeManager.episodeDeletionInProgress = false;
elementContainer.find('button.deleteEpisode').prop('disabled', false);
}
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BitsAndPieces",
"version": "4.3.0",
"version": "4.3.1",
"description": "Bits and Pieces is a user interface framework for sensemaking based on a design idea introduced in the strand of the EU project Learning Layers.",
"repository": {
"type": "git",
Expand Down

0 comments on commit fa370f4

Please sign in to comment.