Commit a783ab54 authored by Anna's avatar Anna
Browse files

contextMenu + buf of dateOfMeeting

parent 9ad74c87
Showing with 63 additions and 74 deletions
+63 -74
......@@ -22,6 +22,7 @@ import org.springframework.stereotype.Component;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
......@@ -77,8 +78,9 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
}
FrontUser jsUser = new FrontUser(response);
//delete password and roles
jsUser.setRoles(null);
ArrayList<String> collect = grantedAuths.stream().map(GrantedAuthority::getAuthority).collect(Collectors.toCollection(ArrayList::new));
jsUser.setRoles(collect.toArray(new String[0]));
//delete password
jsUser.setPassword(null);
jsUser.setBlocked(false);
//set employeeCode
......@@ -89,7 +91,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
}
//set branchCode
if (null == employee || StringUtils.isBlank(employee.getBranchCode())) {
if (StringUtils.isBlank(employee.getBranchCode())) {
jsUser.setBranchCode(StringUtils.EMPTY);
} else {
jsUser.setBranchCode(employee.getBranchCode());
......
......@@ -259,7 +259,16 @@ angular.module('Utils', []).directive('splitJoinFormatter', function(){
}
});
};
/**
* Проверяет роль пользователя требуемой роли
*
* @param user - пользователь
* @param role - роль
*/
this.isUserInRole = function (user, role) {
return user.roles.indexOf(role) != -1;
};
/**
* Вывод alert-сообщения
......
......@@ -13,63 +13,56 @@ app.controller('ShippingCtrl', function($scope, $routeParams, $route,
userService.getUser().then(function successCallback(response) {
$scope.currentUser=response.data;
setupShipmentGrid($scope.shippingListApi.gridOptions);
});
$timeout(function(){
gridUtils.setupGrid('warehouse.shippings', setupShipmentGrid($scope.shippingListApi.gridOptions));
gridUtils.setupGrid('warehouse.shipping.cargoplaces',$scope.cargoPlacesListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.problems',$scope.problemListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.from.list',$scope.fromListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.to.list',$scope.toListApi.gridOptions);
$timeout(function () {
gridUtils.setupGrid('warehouse.shippings', $scope.shippingListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.cargoplaces', $scope.cargoPlacesListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.problems', $scope.problemListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.from.list', $scope.fromListApi.gridOptions);
gridUtils.setupGrid('warehouse.shipping.to.list', $scope.toListApi.gridOptions);
$($scope.shippingListApi.gridOptions.api.gridPanel.eBodyContainer).contextmenu({
'target': '#shipmentContextMenu'
});
});
var setupShipmentGrid = function(grid) {
if (grid != null) {
grid.getContextMenuItems=$scope.getContextMenuItems;
return grid;
}
};
$scope.getContextMenuItems = function(params) {
if(params.node!=null) {
var data=params.node.data;
var result = [
{
//должны быть другие имена
name: 'addDatetimeOfMeetPlan',
action: function () {
//должны быть другие функции
$scope.datetimeOfMeetPlanDialog;
}
},
{
name: 'addDatetimeOfMeet',
action: function () {
$scope.datetimeOfMeetDialog;
}
},
{
name: 'addProblemDialog',
action: function () {
$scope.problemDialog;
}
}
];
for (var i = 0; i < params.defaultItems.length; i++) {
if(params.defaultItems[i] == 'toolPanel'){
result.push(params.defaultItems[i]);
}
}
}else{
var result = params.defaultItems;
}
return result;
}
var setupShipmentGrid = function (grid) {
if (grid != null) {
grid.getContextMenuItems = $scope.getContextMenuItems;
return grid;
}
};
$scope.getContextMenuItems = function (params) {
var result = [];
if (utils.isUserInRole($scope.currentUser, 'ROLE_shipping5.update') && params.node!=null) {
result.push({
name: config.message('shipping.journal.datetimeOfSend'),
action: function () {
$scope.datetimeOfMeetPlanDialog();
}
});
result.push({
name: config.message('shipping.journal.datetimeOfMeet'),
action: function () {
$scope.datetimeOfMeetDialog();
}
});
result.push({
name: config.message('shipping.problems.dialogAdd.title'),
action: function () {
$scope.problemDialog();
}
});
}
for (var i = 0; i < params.defaultItems.length; i++) {
if (params.defaultItems[i] == 'toolPanel') {
result.push(params.defaultItems[i]);
}
}
return result;
}
utils.setupDateRangeValidation($('#filterFromDate'),$('#filterToDate'));
......@@ -416,7 +409,7 @@ app.controller('ShippingCtrl', function($scope, $routeParams, $route,
resizable: false
});
};
$scope.datetimeOfMeetDialog = function() {
$scope.dateOfMeeting = $scope.shippingListApi.single.dateOfMeeting;
......@@ -432,7 +425,7 @@ app.controller('ShippingCtrl', function($scope, $routeParams, $route,
resizable: false
});
};
var doAfterClose = function(callback) {
if(!$scope.shippingListApi.single.dateClosed) {
dialogs.confirmation(config.message('shipping.dialog.close') + " " + ($scope.shippingListApi.single.number || "") + "?").then(function () {
......
......@@ -2,7 +2,6 @@
<#import "/spring.ftl" as spring />
<@components.index app="cdek">
<script src="/commons/javascripts/bootstrap/bootstrap-contextmenu.js"></script>
<script src="/shipping/application/route.js"></script>
<script src="/shipping/application/shipping.js"></script>
</@components.index>
......
......@@ -661,6 +661,7 @@
<input placeholder="<@spring.message "warehouse.dateformat"/>"
type="text"
class="form-control"
data-date-format="DD.MM.YYYY HH:mm"
ng-model="dateOfMeeting">
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar datepickerbutton"></span>
......@@ -677,18 +678,3 @@
<button type="button" class="btn btn-primary" ng-click="editDateOfMeeting()"><@spring.message "template.save"/></button>
</div>
</div>
<div id="shipmentContextMenu">
<ul class="dropdown-menu" role="menu">
<@security.authorize access="hasRole('ROLE_shipping5.update')">
<li>
<a tabindex="-1" ng-click="datetimeOfMeetPlanDialog()" translate><@spring.message "shipping.journal.datetimeOfSend"/></a>
</li>
<li>
<a tabindex="-1" ng-click="datetimeOfMeetDialog()" translate><@spring.message "shipping.journal.datetimeOfMeet"/></a>
</li>
<li>
<a tabindex="-1" ng-click="problemDialog()" translate><@spring.message "shipping.problems.dialogAdd.title"/></a>
</li>
</@security.authorize>
</ul>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment