don't change modified when updating category
This commit is contained in:
parent
b325c13b9e
commit
56c243f734
|
@ -18,6 +18,7 @@ return ['routes' => [
|
|||
['name' => 'notes#get', 'url' => '/notes/{id}', 'verb' => 'GET'],
|
||||
['name' => 'notes#create', 'url' => '/notes', 'verb' => 'POST'],
|
||||
['name' => 'notes#update', 'url' => '/notes/{id}', 'verb' => 'PUT'],
|
||||
['name' => 'notes#category', 'url' => '/notes/{id}/category', 'verb' => 'PUT'],
|
||||
['name' => 'notes#favorite', 'url' => '/notes/{id}/favorite', 'verb' => 'PUT'],
|
||||
['name' => 'notes#destroy', 'url' => '/notes/{id}', 'verb' => 'DELETE'],
|
||||
|
||||
|
|
|
@ -204,8 +204,15 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
#app-content .note-meta .note-category .icon-loading-small {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin: 0px 5px;
|
||||
}
|
||||
|
||||
#app-content .note-meta .edit {
|
||||
opacity: 0.5;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#app-content .note-meta:hover .note-category,
|
||||
#app-content .note-meta:hover .edit {
|
||||
|
|
|
@ -79,16 +79,39 @@ app.controller('NoteController', function($routeParams, $scope, NotesModel,
|
|||
$('#category').autocomplete('search', '');
|
||||
});
|
||||
};
|
||||
$scope.closeCategory = function() {
|
||||
$scope.editCategory = false;
|
||||
$scope.saveCategory = function () {
|
||||
var category = $('#category').val();
|
||||
if($scope.note.category !== category) {
|
||||
$scope.note.category = category;
|
||||
$scope.note.unsaved = true;
|
||||
$scope.autoSave($scope.note);
|
||||
if($scope.note.category === category) {
|
||||
$scope.editCategory = false;
|
||||
return;
|
||||
}
|
||||
$scope.isCategorySaving = true;
|
||||
$scope.note.customPUT({category: category}, 'category', {}, {})
|
||||
.then(
|
||||
function (updatedNote) {
|
||||
$scope.note.category = updatedNote.category;
|
||||
if(category !== updatedNote.category) {
|
||||
OC.Notification.showTemporary(
|
||||
t('notes', 'Updating the note\'s category has failed.'+
|
||||
' Is the target directory writable?')
|
||||
);
|
||||
}
|
||||
},
|
||||
function () {
|
||||
OC.Notification.showTemporary(
|
||||
t('notes', 'Updating the note\'s category has failed.')
|
||||
);
|
||||
}
|
||||
)
|
||||
.finally(
|
||||
function () {
|
||||
$scope.isCategorySaving = false;
|
||||
$scope.editCategory = false;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
$document.unbind('keypress.notes.save');
|
||||
$document.bind('keypress.notes.save', function(event) {
|
||||
if(event.ctrlKey || event.metaKey) {
|
||||
|
|
|
@ -60,13 +60,7 @@ app.factory('SaveQueue', function($q) {
|
|||
note.error = false;
|
||||
note.title = response.title;
|
||||
note.modified = response.modified;
|
||||
if(note.category !== response.category) {
|
||||
OC.Notification.showTemporary(
|
||||
t('notes', 'Updating the note\'s category has failed. ' +
|
||||
'Is the target directory writable?')
|
||||
);
|
||||
note.category = response.category;
|
||||
}
|
||||
note.category = response.category;
|
||||
if(response.content === note.content) {
|
||||
note.unsaved = false;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -106,6 +106,21 @@ class NotesController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $category
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function category($id, $category) {
|
||||
return $this->respond(function () use ($id, $category) {
|
||||
return $this->notesService->update($id, null, $this->userId, $category);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
|
|
|
@ -158,7 +158,7 @@ class NotesService {
|
|||
public function update ($id, $content, $userId, $category=null, $mtime=0) {
|
||||
$notesFolder = $this->getFolderForUser($userId);
|
||||
$file = $this->getFileById($notesFolder, $id);
|
||||
$title = $this->getSafeTitleFromContent($content);
|
||||
$title = $this->getSafeTitleFromContent( $content===null ? $file->getContent() : $content );
|
||||
|
||||
|
||||
// rename/move file with respect to title/category
|
||||
|
@ -199,7 +199,9 @@ class NotesService {
|
|||
$this->logger->error('Moving note '.$id.' ('.$title.') to the desired target has failed with a '.get_class($e).': '.$e->getMessage(), ['app' => $this->appName]);
|
||||
}
|
||||
|
||||
$file->putContent($content);
|
||||
if($content !== null) {
|
||||
$file->putContent($content);
|
||||
}
|
||||
|
||||
if($mtime) {
|
||||
$file->touch($mtime);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<textarea editor notes-timeout-change="onEdit()" name="editor" ng-if="note!==false"></textarea>
|
||||
<div class="note-meta" ng-if="note!==false">
|
||||
<span class="note-category" ng-class="{ uncategorized: !note.category }" title="<?php p($l->t('Category')); ?>" ng-show="!editCategory" ng-click="showEditCategory()">{{ note.category || '<?php p($l->t('Uncategorized')) ?>' | categoryTitle}} <input type="button" class="edit icon icon-rename" title="<?php p($l->t('Edit category')); ?>"></span>
|
||||
<span class="note-category" title="<?php p($l->t('Edit category')); ?>" ng-show="editCategory"><form class="category" ng-submit="closeCategory()"><input type="text" id="category" name="category" ng-blur="closeCategory()" placeholder="<?php p($l->t('Uncategorized')); ?>"><input type="submit" class="icon-confirm" value=""></form></span>
|
||||
<span class="note-category" title="<?php p($l->t('Edit category')); ?>" ng-show="editCategory"><form class="category" ng-submit="saveCategory()"><input type="text" id="category" name="category" ng-disabled="isCategorySaving" ng-blur="saveCategory()" placeholder="<?php p($l->t('Uncategorized')); ?>" ng-class="{ 'icon-loading': isCategorySaving }"><input type="submit" class="icon-confirm" value="" ng-show="!isCategorySaving"><span class="icon icon-loading-small" ng-show="isCategorySaving"></span></form></span>
|
||||
<span class="note-word-count" ng-show="note.content.length > 0">{{note.content | wordCount}}</span>
|
||||
<span class="note-unsaved" ng-show="note.unsaved" title="<?php p($l->t('The note has unsaved changes.')); ?>">*</span>
|
||||
<span class="note-error" ng-show="note.error" ng-click="manualSave()" title="<?php p($l->t('Click here to try again')); ?>"><?php p($l->t('Saving failed!')); ?></span>
|
||||
|
|
Loading…
Reference in New Issue