Skip to content

Commit

Permalink
Merge pull request #779 from linnovate/issue/761
Browse files Browse the repository at this point in the history
fixed showing the second line when click 'Enter' instead of creating …
  • Loading branch information
nevos authored Apr 22, 2018
2 parents bf34e2c + b2f288c commit 1dc1d09
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
};
if($scope.order.field == "custom"){
var timer,
container = $('.containerVertical'),
container = $('.containerVertical'),
scroll = $('.list-table'),
box = $('middlepane-container'),
topBar = $('.filters'),
Expand Down Expand Up @@ -44,7 +44,7 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
entity: context.entityName,
entityId: context.entityId
}, { reload: false });

orderService.setOrder(e, elindex, dropindex, $scope.officeDocuments.length - 1);
});
// $scope.$on('dragularrelease', function (e, el) {
Expand Down Expand Up @@ -108,38 +108,38 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
if (context.entityName !== 'all') {
officeDocument[context.entityName] = context.entity;
}
//
// if (officeDocument.__state === creatingStatuses.NotCreated) {
// officeDocument.__state = creatingStatuses.Creating;

// return OfficeDocumentsService.create(officeDocument).then(function(result) {
// officeDocument.__state = creatingStatuses.Created;
if (officeDocument.__state === creatingStatuses.NotCreated) {
officeDocument.__state = creatingStatuses.Creating;

return OfficeDocumentsService.createDocument(officeDocument).then(function(result) {
Object.assign(officeDocument, result);
officeDocument.__state = creatingStatuses.Created;

// $scope.officeDocuments.push(_(newOfficeDocument).clone());
$scope.officeDocuments.push(_(newOfficeDocument).clone());
OfficeDocumentsService.data.push(officeDocument);

// OfficeDocumentsService.data.push(officeDocument);
return officeDocument;
});
} else

// return officeDocument;
// });
// } else
//
if (officeDocument.__state === creatingStatuses.Created) {

if (!officeDocument.IsTitle)
{
officeDocument.PartTitle = officeDocument.PartTitle.split("...")[0] + officeDocument.title.substring(officeDocument.PartTitle.split("...")[0].length,officeDocument.title.length);
officeDocument.title = officeDocument.title.split("...")[0] + officeDocument.title.substring(officeDocument.title.split("...")[0].length,officeDocument.title.length);
officeDocument.IsTitle = !officeDocument.IsTitle;
}
officeDocument.title = officeDocument.PartTitle;OfficeDocumentsService
officeDocument.title = officeDocument.title;OfficeDocumentsService
return OfficeDocumentsService.update(officeDocument);
}
};

$scope.debouncedUpdate = _.debounce($scope.createOrUpdate, 300);

$scope.searchResults = [];



$scope.create = function(){
var data = {};
Expand All @@ -155,13 +155,13 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
$scope.officeDocuments = $scope.officeDocuments.filter(function(officeDocument){
return officeDocument.status =='new' &&officeDocument.folder&& officeDocument.folder._id==context.entityId ;
});

}else{

$scope.officeDocuments = $scope.officeDocuments.filter(function(officeDocument){
return officeDocument.status == 'new' ;
});

}
$state.go($scope.detailsState+'.activities', {
id: result._id,
Expand Down Expand Up @@ -212,9 +212,17 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
});
};

$scope.select = function(selectedTask) {
$scope.select = function(document) {
var clone = JSON.parse(JSON.stringify(newOfficeDocument));
var index = _.find($scope.officeDocuments, clone);

if($scope.officeDocuments.length == 2){
$scope.officeDocuments.splice(index, 1);
$scope.officeDocuments.push(clone);
}

var currentOfficeDocument = _($scope.officeDocuments).findIndex(function(p) {
return p.id === $state.params.id;
return p._id === document._id;
});

$scope.createOrUpdate($scope.officeDocuments[currentOfficeDocument + 1]).then(function(officeDocument) {
Expand Down Expand Up @@ -303,7 +311,7 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
}
};

$scope.focusAutoComplete = function($event) {
$scope.focusAutoComplete = function($event, document) {
angular.element($event.target).css('box-shadow', 'none')
if ($event.keyCode === 38) {
if ($scope.selectedSuggestion > 0) {
Expand All @@ -317,7 +325,7 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])
$event.preventDefault();
} else if ($event.keyCode === 13) {
var sr = $scope.searchResults[$scope.selectedSuggestion];
$scope.select(sr);
$scope.select(document);
}


Expand Down Expand Up @@ -366,7 +374,7 @@ angular.module('mean.icu.ui.officedocumentlistdirective', [])

}
};


$scope.loadMore = function() {
if (!$scope.isLoading && $scope.loadNext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
ng-attr-contenteditable="{{(!data.displayOnly && haveEditiorsPermissions(data.officeDocument)) && !recycled(data.officeDocument)}}"
strip-br="true"
ng-change="data.searchCb(data.officeDocument.title) || data.updateCb(data.officeDocument)"
ng-keydown="data.focusAutoCompleteCb($event) || data.onEnterCb($event, data.index)"
ng-model="data.officeDocument.title"
ng-keydown="data.focusAutoCompleteCb($event, data.officeDocument) || data.onEnterCb($event, data.index)"
ng-model="data.officeDocument.title"
ng-blur="data.hideAutoCompleteCb(data.officeDocument)">
</td>

<td class="folder">
<span class="tag folder"
title="{{data.officeDocument.folder.title}}"
ng-style="{'background-color': '#' + data.officeDocument.folder.color, 'color': 'white'}"
ng-bind-html="data.officeDocument.folder.title">
ng-bind-html="data.officeDocument.folder.title">
</span>
</td>

Expand Down

0 comments on commit 1dc1d09

Please sign in to comment.