mirror of
https://github.com/standardnotes/app
synced 2026-01-16 19:04:58 -05:00
presentations
This commit is contained in:
@@ -228,20 +228,20 @@ angular.module('app.frontend')
|
||||
this.editUrlPressed = function() {
|
||||
this.showMenu = false;
|
||||
var url = this.publicUrlForNote(this.note);
|
||||
url = url.replace(this.note.presentation.root_path, "");
|
||||
this.url = {base: url, token : this.note.presentation.root_path};
|
||||
url = url.replace(this.note.presentation_name, "");
|
||||
this.url = {base: url, token : this.note.presentation_name};
|
||||
this.editingUrl = true;
|
||||
}
|
||||
|
||||
this.saveUrl = function($event) {
|
||||
$event.target.blur();
|
||||
|
||||
var original = this.note.presentation.relative_path;
|
||||
this.note.presentation.relative_path = this.url.token;
|
||||
var original = this.note.presentation_name;
|
||||
this.note.presentation_name = this.url.token;
|
||||
|
||||
apiController.updatePresentation(this.note, this.note.presentation, function(response){
|
||||
apiController.saveItems([this.note], function(response){
|
||||
if(!response) {
|
||||
this.note.presentation.relative_path = original;
|
||||
this.note.presentation_name = original;
|
||||
this.url.token = original;
|
||||
alert("This URL is not available.");
|
||||
} else {
|
||||
@@ -259,14 +259,14 @@ angular.module('app.frontend')
|
||||
a.click();
|
||||
}
|
||||
|
||||
apiController.shareItem(this.user, this.note, function(note){
|
||||
apiController.shareItem(this.note, function(note){
|
||||
openInNewTab(this.publicUrlForNote(note));
|
||||
}.bind(this))
|
||||
this.showMenu = false;
|
||||
}
|
||||
|
||||
this.unshareNote = function() {
|
||||
apiController.unshareItem(this.user, this.note, function(note){
|
||||
apiController.unshareItem(this.note, function(note){
|
||||
|
||||
})
|
||||
this.showMenu = false;
|
||||
|
||||
@@ -25,7 +25,7 @@ angular.module('app.frontend')
|
||||
}
|
||||
}
|
||||
})
|
||||
.controller('NotesCtrl', function (apiController, $timeout, ngDialog, $rootScope) {
|
||||
.controller('NotesCtrl', function (apiController, $timeout, $rootScope) {
|
||||
|
||||
$rootScope.$on("editorFocused", function(){
|
||||
this.showMenu = false;
|
||||
@@ -81,38 +81,16 @@ angular.module('app.frontend')
|
||||
return;
|
||||
}
|
||||
|
||||
var callback = function(username) {
|
||||
apiController.shareItem(this.user, this.tag, function(response){
|
||||
})
|
||||
}.bind(this);
|
||||
|
||||
if(!this.user.username) {
|
||||
ngDialog.open({
|
||||
template: 'frontend/modals/username.html',
|
||||
controller: 'UsernameModalCtrl',
|
||||
resolve: {
|
||||
user: function() {return this.user}.bind(this),
|
||||
callback: function() {return callback}
|
||||
},
|
||||
className: 'ngdialog-theme-default',
|
||||
disableAnimation: true
|
||||
});
|
||||
} else {
|
||||
callback(this.user.username);
|
||||
}
|
||||
apiController.shareItem(this.tag, function(response){})
|
||||
}
|
||||
|
||||
this.selectedTagUnshare = function() {
|
||||
this.showMenu = false;
|
||||
apiController.unshareItem(this.user, this.tag, function(response){
|
||||
apiController.unshareItem(this.tag, function(response){
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
this.publicUrlForTag = function() {
|
||||
return this.tag.presentation.url;
|
||||
}
|
||||
|
||||
this.selectFirstNote = function(createNew) {
|
||||
var visibleNotes = this.tag.notes.filter(function(note){
|
||||
return note.visible;
|
||||
|
||||
@@ -64,8 +64,13 @@ class Item {
|
||||
// should be overriden to manage local properties
|
||||
}
|
||||
|
||||
referencesAffectedBySharingChange() {
|
||||
// should be overriden to determine which references should be decrypted/encrypted
|
||||
return null;
|
||||
}
|
||||
|
||||
isPublic() {
|
||||
return this.presentation;
|
||||
return this.presentation_name;
|
||||
}
|
||||
|
||||
isEncrypted() {
|
||||
@@ -77,7 +82,7 @@ class Item {
|
||||
}
|
||||
|
||||
presentationURL() {
|
||||
return this.presentation.url;
|
||||
return this.presentation_url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ class Note extends Item {
|
||||
this.tags = this.referencesMatchingContentType("Tag");
|
||||
}
|
||||
|
||||
referencesAffectedBySharingChange() {
|
||||
return super.referencesAffectedBySharingChange();
|
||||
}
|
||||
|
||||
get hasOnePublicTag() {
|
||||
var hasPublicTag = false;
|
||||
this.tags.forEach(function(tag){
|
||||
|
||||
@@ -20,4 +20,8 @@ class Tag extends Item {
|
||||
super.updateReferencesLocalMapping();
|
||||
this.notes = this.referencesMatchingContentType("Note");
|
||||
}
|
||||
|
||||
referencesAffectedBySharingChange() {
|
||||
return this.referencesMatchingContentType("Note");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,34 +18,6 @@ angular.module('app.frontend')
|
||||
}
|
||||
})
|
||||
|
||||
.state('presentation', {
|
||||
url: '/:root_path',
|
||||
parent: 'base',
|
||||
views: {
|
||||
'content@' : {
|
||||
templateUrl: 'frontend/presentation.html',
|
||||
controller: "PresentationCtrl"
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
presentation: getPresentation
|
||||
}
|
||||
})
|
||||
|
||||
.state('tag', {
|
||||
url: '/:root_path/:secondary_path',
|
||||
parent: 'base',
|
||||
views: {
|
||||
'content@' : {
|
||||
templateUrl: 'frontend/presentation.html',
|
||||
controller: "PresentationCtrl"
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
presentation: getPresentation
|
||||
}
|
||||
})
|
||||
|
||||
// Auth routes
|
||||
.state('auth', {
|
||||
abstract: true,
|
||||
@@ -89,20 +61,6 @@ angular.module('app.frontend')
|
||||
}
|
||||
});
|
||||
|
||||
function getPresentation ($q, $state, $stateParams, Restangular) {
|
||||
var deferred = $q.defer();
|
||||
var restangularQuery = Restangular.one('presentations', 'show_by_path');
|
||||
restangularQuery.get({root_path: $stateParams.root_path, secondary_path: $stateParams.secondary_path})
|
||||
.then(function(response) {
|
||||
deferred.resolve(response);
|
||||
})
|
||||
.catch(function(response) {
|
||||
$state.go('404');
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Default fall back route
|
||||
$urlRouterProvider.otherwise(function($injector, $location){
|
||||
var state = $injector.get('$state');
|
||||
|
||||
@@ -20,11 +20,11 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
|
||||
this.$get = function(Restangular, modelManager) {
|
||||
return new ApiController(Restangular, modelManager);
|
||||
this.$get = function(Restangular, modelManager, ngDialog) {
|
||||
return new ApiController(Restangular, modelManager, ngDialog);
|
||||
}
|
||||
|
||||
function ApiController(Restangular, modelManager) {
|
||||
function ApiController(Restangular, modelManager, ngDialog) {
|
||||
|
||||
this.setUser = function(user) {
|
||||
this.user = user;
|
||||
@@ -65,6 +65,7 @@ angular.module('app.frontend')
|
||||
Restangular.one("users/current").get().then(function(response){
|
||||
var plain = response.plain();
|
||||
var items = plain.items;
|
||||
console.log("retreived items", plain);
|
||||
this.decryptItemsWithLocalKey(items);
|
||||
callback(plain);
|
||||
}.bind(this))
|
||||
@@ -143,9 +144,9 @@ angular.module('app.frontend')
|
||||
*/
|
||||
|
||||
this.setUsername = function(user, username, callback) {
|
||||
var request = Restangular.one("users", user.uuid).one("set_username");
|
||||
var request = Restangular.one("users", user.uuid);
|
||||
request.username = username;
|
||||
request.post().then(function(response){
|
||||
request.patch().then(function(response){
|
||||
callback(response.plain());
|
||||
})
|
||||
}
|
||||
@@ -205,9 +206,6 @@ angular.module('app.frontend')
|
||||
request.post().then(function(response) {
|
||||
var savedItems = response.items;
|
||||
console.log("response items", savedItems);
|
||||
// items.forEach(function(item) {
|
||||
// _.merge(item, _.find(savedItems, {uuid: item.uuid}));
|
||||
// })
|
||||
callback(response);
|
||||
})
|
||||
}
|
||||
@@ -215,7 +213,8 @@ angular.module('app.frontend')
|
||||
this.createRequestParamsForItem = function(item) {
|
||||
var itemCopy = _.cloneDeep(item);
|
||||
|
||||
var params = {uuid: item.uuid, content_type: item.content_type};
|
||||
var params = {uuid: item.uuid, content_type: item.content_type, presentation_name: item.presentation_name};
|
||||
|
||||
itemCopy.content.references = _.map(itemCopy.content.references, function(reference){
|
||||
return {uuid: reference.uuid, content_type: reference.content_type};
|
||||
})
|
||||
@@ -248,55 +247,43 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
this.shareItem = function(item, callback) {
|
||||
console.log("sharing item", item);
|
||||
if(!this.user.uuid) {
|
||||
alert("You must be signed in to share.");
|
||||
} else {
|
||||
Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations").post()
|
||||
.then(function(response){
|
||||
var presentation = response.plain();
|
||||
_.merge(item, {presentation: presentation});
|
||||
callback(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// decrypt references
|
||||
if(item.references.length > 0) {
|
||||
this.saveBatchItems(item.references, function(success){})
|
||||
}
|
||||
})
|
||||
var shareFn = function() {
|
||||
item.presentation_name = "_auto_";
|
||||
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||
this.saveItems(needsUpdate, function(success){})
|
||||
}.bind(this)
|
||||
|
||||
if(!this.user.username) {
|
||||
ngDialog.open({
|
||||
template: 'frontend/modals/username.html',
|
||||
controller: 'UsernameModalCtrl',
|
||||
resolve: {
|
||||
user: function() {return this.user}.bind(this),
|
||||
callback: function() {
|
||||
return shareFn;
|
||||
}
|
||||
},
|
||||
className: 'ngdialog-theme-default',
|
||||
disableAnimation: true
|
||||
});
|
||||
} else {
|
||||
shareFn();
|
||||
}
|
||||
}
|
||||
|
||||
this.unshareItem = function(item, callback) {
|
||||
var request = Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations", item.presentation.uuid);
|
||||
request.remove().then(function(response){
|
||||
item.presentation = null;
|
||||
callback(null);
|
||||
|
||||
// encrypt references
|
||||
if(item.references.length > 0) {
|
||||
this.saveBatchItems(item.references, function(success){})
|
||||
}
|
||||
})
|
||||
console.log("unsharing item", item);
|
||||
item.presentation_name = null;
|
||||
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||
this.saveItems(needsUpdate, function(success){})
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Presentations
|
||||
*/
|
||||
|
||||
this.updatePresentation = function(resource, presentation, callback) {
|
||||
var request = Restangular.one("users", this.user.uuid)
|
||||
.one("items", resource.uuid)
|
||||
.one("presentations", resource.presentation.uuid);
|
||||
_.merge(request, presentation);
|
||||
request.patch().then(function(response){
|
||||
callback(response.plain());
|
||||
})
|
||||
.catch(function(error){
|
||||
callback(nil);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Import
|
||||
*/
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
%span.sr-only
|
||||
|
||||
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu && !ctrl.note.locked"}
|
||||
-# %li
|
||||
-# %a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.saveNote($event, note)"} Save
|
||||
-# .shortcut Cmd + S
|
||||
%li
|
||||
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"} Toggle Fullscreen
|
||||
.shortcut Cmd + O
|
||||
@@ -40,7 +37,7 @@
|
||||
.panel-body{"style" => "text-align: center; color: black;"}
|
||||
This editor is Markdown enabled.
|
||||
.menu-right-container
|
||||
.public-link{"ng-if" => "ctrl.note.presentation"}
|
||||
.public-link{"ng-if" => "ctrl.note.isPublic()"}
|
||||
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForNote(ctrl.note)}}", "target" => "_blank"}
|
||||
%span.icon-rss.icon
|
||||
{{ctrl.publicUrlForNote(note)}}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagDelete()"} Delete Tag
|
||||
.menu-right-container
|
||||
.public-link{"ng-if" => "ctrl.tag.presentation"}
|
||||
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForTag(ctrl.tag)}}", "target" => "_blank"}
|
||||
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.tag.presentationURL()}}", "target" => "_blank"}
|
||||
%span.icon-rss.icon
|
||||
{{ctrl.publicUrlForTag()}}
|
||||
{{ctrl.tag.presentationURL()}}
|
||||
.edit-url{"ng-if" => "ctrl.editingUrl"}
|
||||
{{ctrl.url.base}}
|
||||
%input.input{"ng-model" => "ctrl.url.token", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveUrl($event)",
|
||||
|
||||
182
vendor/assets/javascripts/transpiled.js
vendored
182
vendor/assets/javascripts/transpiled.js
vendored
@@ -52,30 +52,6 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
|
||||
controller: 'HomeCtrl'
|
||||
}
|
||||
}
|
||||
}).state('presentation', {
|
||||
url: '/:root_path',
|
||||
parent: 'base',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'frontend/presentation.html',
|
||||
controller: "PresentationCtrl"
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
presentation: getPresentation
|
||||
}
|
||||
}).state('tag', {
|
||||
url: '/:root_path/:secondary_path',
|
||||
parent: 'base',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'frontend/presentation.html',
|
||||
controller: "PresentationCtrl"
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
presentation: getPresentation
|
||||
}
|
||||
})
|
||||
|
||||
// Auth routes
|
||||
@@ -117,18 +93,6 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
|
||||
}
|
||||
});
|
||||
|
||||
function getPresentation($q, $state, $stateParams, Restangular) {
|
||||
var deferred = $q.defer();
|
||||
var restangularQuery = Restangular.one('presentations', 'show_by_path');
|
||||
restangularQuery.get({ root_path: $stateParams.root_path, secondary_path: $stateParams.secondary_path }).then(function (response) {
|
||||
deferred.resolve(response);
|
||||
}).catch(function (response) {
|
||||
$state.go('404');
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Default fall back route
|
||||
$urlRouterProvider.otherwise(function ($injector, $location) {
|
||||
var state = $injector.get('$state');
|
||||
@@ -372,20 +336,20 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
this.editUrlPressed = function () {
|
||||
this.showMenu = false;
|
||||
var url = this.publicUrlForNote(this.note);
|
||||
url = url.replace(this.note.presentation.root_path, "");
|
||||
this.url = { base: url, token: this.note.presentation.root_path };
|
||||
url = url.replace(this.note.presentation_name, "");
|
||||
this.url = { base: url, token: this.note.presentation_name };
|
||||
this.editingUrl = true;
|
||||
};
|
||||
|
||||
this.saveUrl = function ($event) {
|
||||
$event.target.blur();
|
||||
|
||||
var original = this.note.presentation.relative_path;
|
||||
this.note.presentation.relative_path = this.url.token;
|
||||
var original = this.note.presentation_name;
|
||||
this.note.presentation_name = this.url.token;
|
||||
|
||||
apiController.updatePresentation(this.note, this.note.presentation, function (response) {
|
||||
apiController.saveItems([this.note], function (response) {
|
||||
if (!response) {
|
||||
this.note.presentation.relative_path = original;
|
||||
this.note.presentation_name = original;
|
||||
this.url.token = original;
|
||||
alert("This URL is not available.");
|
||||
} else {
|
||||
@@ -403,14 +367,14 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
a.click();
|
||||
}
|
||||
|
||||
apiController.shareItem(this.user, this.note, function (note) {
|
||||
apiController.shareItem(this.note, function (note) {
|
||||
openInNewTab(this.publicUrlForNote(note));
|
||||
}.bind(this));
|
||||
this.showMenu = false;
|
||||
};
|
||||
|
||||
this.unshareNote = function () {
|
||||
apiController.unshareItem(this.user, this.note, function (note) {});
|
||||
apiController.unshareItem(this.note, function (note) {});
|
||||
this.showMenu = false;
|
||||
};
|
||||
|
||||
@@ -767,7 +731,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
});
|
||||
}
|
||||
};
|
||||
}).controller('NotesCtrl', function (apiController, $timeout, ngDialog, $rootScope) {
|
||||
}).controller('NotesCtrl', function (apiController, $timeout, $rootScope) {
|
||||
|
||||
$rootScope.$on("editorFocused", function () {
|
||||
this.showMenu = false;
|
||||
@@ -823,37 +787,12 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||
return;
|
||||
}
|
||||
|
||||
var _callback = function (username) {
|
||||
apiController.shareItem(this.user, this.tag, function (response) {});
|
||||
}.bind(this);
|
||||
|
||||
if (!this.user.username) {
|
||||
ngDialog.open({
|
||||
template: 'frontend/modals/username.html',
|
||||
controller: 'UsernameModalCtrl',
|
||||
resolve: {
|
||||
user: function () {
|
||||
return this.user;
|
||||
}.bind(this),
|
||||
callback: function callback() {
|
||||
return _callback;
|
||||
}
|
||||
},
|
||||
className: 'ngdialog-theme-default',
|
||||
disableAnimation: true
|
||||
});
|
||||
} else {
|
||||
_callback(this.user.username);
|
||||
}
|
||||
apiController.shareItem(this.tag, function (response) {});
|
||||
};
|
||||
|
||||
this.selectedTagUnshare = function () {
|
||||
this.showMenu = false;
|
||||
apiController.unshareItem(this.user, this.tag, function (response) {});
|
||||
};
|
||||
|
||||
this.publicUrlForTag = function () {
|
||||
return this.tag.presentation.url;
|
||||
apiController.unshareItem(this.tag, function (response) {});
|
||||
};
|
||||
|
||||
this.selectFirstNote = function (createNew) {
|
||||
@@ -1090,10 +1029,16 @@ var Item = function () {
|
||||
value: function updateReferencesLocalMapping() {
|
||||
// should be overriden to manage local properties
|
||||
}
|
||||
}, {
|
||||
key: 'referencesAffectedBySharingChange',
|
||||
value: function referencesAffectedBySharingChange() {
|
||||
// should be overriden to determine which references should be decrypted/encrypted
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: 'isPublic',
|
||||
value: function isPublic() {
|
||||
return this.presentation;
|
||||
return this.presentation_name;
|
||||
}
|
||||
}, {
|
||||
key: 'isEncrypted',
|
||||
@@ -1108,7 +1053,7 @@ var Item = function () {
|
||||
}, {
|
||||
key: 'presentationURL',
|
||||
value: function presentationURL() {
|
||||
return this.presentation.url;
|
||||
return this.presentation_url;
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -1141,6 +1086,11 @@ var Note = function (_Item) {
|
||||
_get(Note.prototype.__proto__ || Object.getPrototypeOf(Note.prototype), 'updateReferencesLocalMapping', this).call(this);
|
||||
this.tags = this.referencesMatchingContentType("Tag");
|
||||
}
|
||||
}, {
|
||||
key: 'referencesAffectedBySharingChange',
|
||||
value: function referencesAffectedBySharingChange() {
|
||||
return _get(Note.prototype.__proto__ || Object.getPrototypeOf(Note.prototype), 'referencesAffectedBySharingChange', this).call(this);
|
||||
}
|
||||
}, {
|
||||
key: 'toJSON',
|
||||
value: function toJSON() {
|
||||
@@ -1207,6 +1157,11 @@ var Tag = function (_Item2) {
|
||||
_get(Tag.prototype.__proto__ || Object.getPrototypeOf(Tag.prototype), 'updateReferencesLocalMapping', this).call(this);
|
||||
this.notes = this.referencesMatchingContentType("Note");
|
||||
}
|
||||
}, {
|
||||
key: 'referencesAffectedBySharingChange',
|
||||
value: function referencesAffectedBySharingChange() {
|
||||
return this.referencesMatchingContentType("Note");
|
||||
}
|
||||
}, {
|
||||
key: 'content_type',
|
||||
get: function get() {
|
||||
@@ -1244,11 +1199,11 @@ var User = function User(json_obj) {
|
||||
return url;
|
||||
};
|
||||
|
||||
this.$get = function (Restangular, modelManager) {
|
||||
return new ApiController(Restangular, modelManager);
|
||||
this.$get = function (Restangular, modelManager, ngDialog) {
|
||||
return new ApiController(Restangular, modelManager, ngDialog);
|
||||
};
|
||||
|
||||
function ApiController(Restangular, modelManager) {
|
||||
function ApiController(Restangular, modelManager, ngDialog) {
|
||||
|
||||
this.setUser = function (user) {
|
||||
this.user = user;
|
||||
@@ -1288,6 +1243,7 @@ var User = function User(json_obj) {
|
||||
Restangular.one("users/current").get().then(function (response) {
|
||||
var plain = response.plain();
|
||||
var items = plain.items;
|
||||
console.log("retreived items", plain);
|
||||
this.decryptItemsWithLocalKey(items);
|
||||
callback(plain);
|
||||
}.bind(this)).catch(function (error) {
|
||||
@@ -1364,9 +1320,9 @@ var User = function User(json_obj) {
|
||||
*/
|
||||
|
||||
this.setUsername = function (user, username, callback) {
|
||||
var request = Restangular.one("users", user.uuid).one("set_username");
|
||||
var request = Restangular.one("users", user.uuid);
|
||||
request.username = username;
|
||||
request.post().then(function (response) {
|
||||
request.patch().then(function (response) {
|
||||
callback(response.plain());
|
||||
});
|
||||
};
|
||||
@@ -1424,9 +1380,6 @@ var User = function User(json_obj) {
|
||||
request.post().then(function (response) {
|
||||
var savedItems = response.items;
|
||||
console.log("response items", savedItems);
|
||||
// items.forEach(function(item) {
|
||||
// _.merge(item, _.find(savedItems, {uuid: item.uuid}));
|
||||
// })
|
||||
callback(response);
|
||||
});
|
||||
};
|
||||
@@ -1434,7 +1387,8 @@ var User = function User(json_obj) {
|
||||
this.createRequestParamsForItem = function (item) {
|
||||
var itemCopy = _.cloneDeep(item);
|
||||
|
||||
var params = { uuid: item.uuid, content_type: item.content_type };
|
||||
var params = { uuid: item.uuid, content_type: item.content_type, presentation_name: item.presentation_name };
|
||||
|
||||
itemCopy.content.references = _.map(itemCopy.content.references, function (reference) {
|
||||
return { uuid: reference.uuid, content_type: reference.content_type };
|
||||
});
|
||||
@@ -1464,47 +1418,43 @@ var User = function User(json_obj) {
|
||||
};
|
||||
|
||||
this.shareItem = function (item, callback) {
|
||||
console.log("sharing item", item);
|
||||
if (!this.user.uuid) {
|
||||
alert("You must be signed in to share.");
|
||||
} else {
|
||||
Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations").post().then(function (response) {
|
||||
var presentation = response.plain();
|
||||
_.merge(item, { presentation: presentation });
|
||||
callback(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// decrypt references
|
||||
if (item.references.length > 0) {
|
||||
this.saveBatchItems(item.references, function (success) {});
|
||||
}
|
||||
var shareFn = function () {
|
||||
item.presentation_name = "_auto_";
|
||||
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||
this.saveItems(needsUpdate, function (success) {});
|
||||
}.bind(this);
|
||||
|
||||
if (!this.user.username) {
|
||||
ngDialog.open({
|
||||
template: 'frontend/modals/username.html',
|
||||
controller: 'UsernameModalCtrl',
|
||||
resolve: {
|
||||
user: function () {
|
||||
return this.user;
|
||||
}.bind(this),
|
||||
callback: function callback() {
|
||||
return shareFn;
|
||||
}
|
||||
},
|
||||
className: 'ngdialog-theme-default',
|
||||
disableAnimation: true
|
||||
});
|
||||
} else {
|
||||
shareFn();
|
||||
}
|
||||
};
|
||||
|
||||
this.unshareItem = function (item, callback) {
|
||||
var request = Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations", item.presentation.uuid);
|
||||
request.remove().then(function (response) {
|
||||
item.presentation = null;
|
||||
callback(null);
|
||||
|
||||
// encrypt references
|
||||
if (item.references.length > 0) {
|
||||
this.saveBatchItems(item.references, function (success) {});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Presentations
|
||||
*/
|
||||
|
||||
this.updatePresentation = function (resource, presentation, callback) {
|
||||
var request = Restangular.one("users", this.user.uuid).one("items", resource.uuid).one("presentations", resource.presentation.uuid);
|
||||
_.merge(request, presentation);
|
||||
request.patch().then(function (response) {
|
||||
callback(response.plain());
|
||||
}).catch(function (error) {
|
||||
callback(nil);
|
||||
});
|
||||
console.log("unsharing item", item);
|
||||
item.presentation_name = null;
|
||||
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||
this.saveItems(needsUpdate, function (success) {});
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
2
vendor/assets/javascripts/transpiled.js.map
vendored
2
vendor/assets/javascripts/transpiled.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user