修复点击备忘录里面的分类未响应的bug

This commit is contained in:
luchenqun 2017-07-26 22:16:10 +08:00
parent 69dece9aba
commit 7637d7662d
2 changed files with 24 additions and 25 deletions

View File

@ -181,12 +181,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
$scope.content = content; $scope.content = content;
$scope.currentNoteId = id; $scope.currentNoteId = id;
$scope.currentTagId = tagId; $scope.currentTagId = tagId;
$scope.tags.forEach((tag) => { updateSelectTag(tagId);
tag.clicked = false;
if (tag.id == tagId) {
tag.clicked = true;
}
})
} }
$scope.updateNote = function() { $scope.updateNote = function() {
@ -257,6 +252,27 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
$scope.hoverNote = note; $scope.hoverNote = note;
} }
$scope.clickTag = function(id) {
$scope.currentTagId = id;
updateSelectTag(id);
if ($scope.add || $scope.edit) {
} else {
getNotes($scope.currentTagId);
}
}
function updateSelectTag(tagId) {
$scope.tags.forEach((tag) => {
tag.clicked = false;
if (tag.id == tagId) {
tag.clicked = true;
t = tag;
}
})
}
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键 // 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) { $document.bind("keydown", function(event) {
$scope.$apply(function() { $scope.$apply(function() {
@ -337,23 +353,6 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
}); });
} }
$scope.clickTag = function(id, clicked) {
$scope.currentTagId = id;
// 只允许选择一个
$scope.tags.forEach((tag) => {
tag.clicked = false;
if (tag.id == id) {
tag.clicked = true;
}
})
if ($scope.add || $scope.edit) {
} else {
getNotes($scope.currentTagId);
}
}
$('.js-note-card').transition('hide'); $('.js-note-card').transition('hide');
function transition() { function transition() {

View File

@ -1,5 +1,5 @@
<div class="ui segment js-note-card"> <div class="ui segment js-note-card">
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id, !tag.clicked)" ng-show="!loadBusy">{{ tag.name }}</div> <div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id)" ng-show="!loadBusy">{{ tag.name }}</div>
<div class="ui form" ng-show="add"> <div class="ui form" ng-show="add">
<div class="required field"> <div class="required field">
<label>内容</label> <label>内容</label>
@ -37,7 +37,7 @@
<i class="add to calendar icon"></i> <i class="add to calendar icon"></i>
<span title="{{note.created_at}}" class="need_to_be_rendered" data-timeago="{{ note.created_at }}"></span> <span title="{{note.created_at}}" class="need_to_be_rendered" data-timeago="{{ note.created_at }}"></span>
</span> </span>
<div class="ui label" ng-click="clickTag(tag.id, !tag.clicked)" style="margin:3px 0px 0px 10px;cursor:default;">{{ note.tagName }}</div> <div class="ui label" ng-click="clickTag(note.tag_id)" style="margin:3px 0px 0px 10px;cursor:default;">{{ note.tagName }}</div>
<i class="ellipsis horizontal icon right floated" style="margin-top:8px;" ng-mouseover="note.edit=true;"></i> <i class="ellipsis horizontal icon right floated" style="margin-top:8px;" ng-mouseover="note.edit=true;"></i>
</div> </div>
<div class="extra content" ng-show="note.edit" ng-mouseleave="note.edit=false;" style="height:50px;"> <div class="extra content" ng-show="note.edit" ng-mouseleave="note.edit=false;" style="height:50px;">