Commit c7aade6e authored by Florian Azizian's avatar Florian Azizian

FIX #12091 Disable search and menu if no service available + improve shipping…

FIX #12091 Disable search and menu if no service available + improve shipping controls + improve mailing without contact + improve menu of note entities restrictrion
parent 94409f79
......@@ -55,7 +55,7 @@
"@types/datatables.net": "^1.10.18",
"@types/jquery": "^2.0.53",
"@types/node": "^7.10.8",
"ajv": "^6.11.0",
"ajv": "^6.12.0",
"hammerjs": "^2.0.8",
"html-minifier": "^3.5.21",
"ng2-dnd": "^5.0.2",
......@@ -63,7 +63,7 @@
"nodemon": "^1.19.1",
"npm-check-updates": "^3.2.0",
"rxjs": "^6.5.2",
"tslib": "^1.10.0",
"tslib": "^1.11.0",
"typescript": "3.5.3",
"url-loader": "^1.1.2",
"webpack": "^4.39.2"
......
......@@ -14,7 +14,6 @@ namespace Action\controllers;
use AcknowledgementReceipt\models\AcknowledgementReceiptModel;
use Action\models\ActionModel;
use Attachment\controllers\AttachmentController;
use Attachment\models\AttachmentModel;
use Basket\models\BasketModel;
use Basket\models\GroupBasketRedirectModel;
......@@ -645,9 +644,9 @@ class PreProcessActionController
{
$mailevaConfig = CoreConfigModel::getMailevaConfiguration();
if (empty($mailevaConfig)) {
return $response->withStatus(400)->withJson(['errors' => 'Maileva configuration does not exist', 'lang' => 'missingMailevaConfig']);
return $response->withJson(['fatalError' => 'Maileva configuration does not exist', 'reason' => 'missingMailevaConfig']);
} elseif (!$mailevaConfig['enabled']) {
return $response->withStatus(400)->withJson(['errors' => 'Maileva configuration is disabled', 'lang' => 'disabledMailevaConfig']);
return $response->withJson(['fatalError' => 'Maileva configuration is disabled', 'reason' => 'disabledMailevaConfig']);
}
$data = $request->getParsedBody();
......
......@@ -672,9 +672,6 @@ class AttachmentController
'where' => ['res_id = ?', 'type = ?', 'mode = ?'],
'data' => [$attachment['res_id_master'], 'contact', $mode]
]);
if (empty($recipients)) {
return true;
}
$docserver = DocserverModel::getByDocserverId(['docserverId' => $attachment['docserver_id'], 'select' => ['path_template']]);
if (empty($docserver['path_template']) || !is_dir($docserver['path_template'])) {
......@@ -685,12 +682,10 @@ class AttachmentController
return ['errors' => 'Attachment not found on docserver'];
}
foreach ($recipients as $key => $recipient) {
$chrono = $attachment['identifier'] . '-' . ($key+1);
if (empty($recipients)) {
$mergedDocument = MergeController::mergeDocument([
'path' => $pathToAttachment,
'data' => ['userId' => $args['userId'], 'recipientId' => $recipient['item_id'], 'recipientType' => 'contact']
'data' => ['userId' => $args['userId']]
]);
$data = [
......@@ -698,7 +693,7 @@ class AttachmentController
'encodedFile' => $mergedDocument['encodedDocument'],
'format' => $attachment['format'],
'resIdMaster' => $attachment['res_id_master'],
'chrono' => $chrono,
'chrono' => $attachment['identifier'],
'type' => $attachment['attachment_type'],
'recipientId' => $recipient['item_id'],
'recipientType' => 'contact',
......@@ -709,6 +704,30 @@ class AttachmentController
if (!empty($isStored['errors'])) {
return ['errors' => $isStored['errors']];
}
} else {
foreach ($recipients as $key => $recipient) {
$mergedDocument = MergeController::mergeDocument([
'path' => $pathToAttachment,
'data' => ['userId' => $args['userId'], 'recipientId' => $recipient['item_id'], 'recipientType' => 'contact']
]);
$data = [
'title' => $attachment['title'],
'encodedFile' => $mergedDocument['encodedDocument'],
'format' => $attachment['format'],
'resIdMaster' => $attachment['res_id_master'],
'chrono' => $attachment['identifier'] . '-' . ($key+1),
'type' => $attachment['attachment_type'],
'recipientId' => $recipient['item_id'],
'recipientType' => 'contact',
'inSignatureBook' => true
];
$isStored = StoreController::storeAttachment($data);
if (!empty($isStored['errors'])) {
return ['errors' => $isStored['errors']];
}
}
}
AttachmentModel::update([
......
......@@ -3,7 +3,10 @@
<div *ngIf="loading" class="loading" style="display:flex;height:100%;">
<mat-spinner style="margin:auto;"></mat-spinner>
</div>
<div *ngIf="shippings.length == 0" class="alert-message alert-message-danger mailList" role="alert">
<div *ngIf="!functions.empty(fatalError)" class="alert-message alert-message-danger mailList" role="alert">
{{lang[fatalError.reason]}}
</div>
<div *ngIf="functions.empty(fatalError) && shippings.length == 0" class="alert-message alert-message-danger mailList" role="alert">
{{lang.noShippingTemplate}} :<br />
<div class="mailList">
<ul>
......
......@@ -6,6 +6,7 @@ import { HttpClient } from '@angular/common/http';
import { NoteEditorComponent } from '../../notes/note-editor.component';
import { catchError, finalize, tap } from 'rxjs/operators';
import { of } from 'rxjs';
import { FunctionsService } from '../../../service/functions.service';
@Component({
templateUrl: "send-shipping-action.component.html",
......@@ -43,10 +44,16 @@ export class SendShippingActionComponent implements OnInit {
icon: 'fas fa-shipping-fast'
}
};
fatalError: any[] = [];
@ViewChild('noteEditor', { static: false }) noteEditor: NoteEditorComponent;
constructor(public http: HttpClient, private notify: NotificationService, public dialogRef: MatDialogRef<SendShippingActionComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { }
constructor(
public http: HttpClient,
private notify: NotificationService,
public dialogRef: MatDialogRef<SendShippingActionComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
public functions: FunctionsService) { }
ngOnInit(): void {
this.loading = true;
......@@ -84,10 +91,15 @@ export class SendShippingActionComponent implements OnInit {
checkShipping() {
this.http.post(`../../rest/resourcesList/users/${this.data.userId}/groups/${this.data.groupId}/baskets/${this.data.basketId}/actions/${this.data.action.id}/checkShippings`, { resources: this.data.resIds }).pipe(
tap((data: any) => {
this.shippings = data.shippingTemplates;
this.mailsNotSend = data.canNotSend;
this.entitiesList = data.entities;
this.attachList = data.resources;
if (!this.functions.empty(data.fatalError)) {
this.fatalError = data;
this.shippings = [];
} else {
this.shippings = data.shippingTemplates;
this.mailsNotSend = data.canNotSend;
this.entitiesList = data.entities;
this.attachList = data.resources;
}
}),
finalize(() => this.loading = false),
catchError((err: any) => {
......
......@@ -4,7 +4,7 @@
<input type="hidden" name="meta[]" value="baskets_clause#baskets_clause#select_simple">
<input type="hidden" name="meta[]" value="welcome#welcome#welcome">
<input type="hidden" name="baskets_clause" value="true">
<mat-form-field floatLabel="never" style="width:100%;margin-top: -3px;margin-left:-13px;font-size: 12px;">
<mat-form-field floatLabel="never" style="width:100%;margin-top: -3px;margin-left:-13px;font-size: 12px;" *ngIf="privilegeService.hasCurrentUserPrivilege('adv_search_mlb')">
<input #searchInput="matInput" matInput type="text" (blur)="hideSearch = !hideSearch" name="welcome" title="{{lang.searchMails}}" placeholder="{{lang.searchMails}}">
<button mat-icon-button matSuffix *ngIf="!appService.getViewMode()" style="opacity:0.5;">
<mat-icon class="fa fa-search" style="font-size:22px;"></mat-icon>
......@@ -13,7 +13,8 @@
<input #searchHome type="submit" name="submit" value="" style="display:none;">
</form>
<button title="{{lang.quickSearchInfo + ' : '+ lang.quickSearchTarget}}" (click)="showSearchInput()" mat-icon-button *ngIf="hideSearch" style="opacity:0.5;">
<button title="{{lang.quickSearchInfo + ' : '+ lang.quickSearchTarget}}" (click)="showSearchInput()" mat-icon-button *ngIf="hideSearch && privilegeService.hasCurrentUserPrivilege('adv_search_mlb')"
style="opacity:0.5;">
<mat-icon class="fa fa-search" style="font-size:22px;"></mat-icon>
</button>
......@@ -28,6 +29,9 @@
<br />{{shortcut.label}}
</button>
</ng-container>
<div *ngIf="functions.empty(menus)" class="noAvailableMenu">
{{lang.noAvailableMenu}}
</div>
</mat-menu>
<button *ngIf="!appService.getViewMode()" mat-button [matMenuTriggerFor]="menu">
<mat-icon mat-list-icon class="fa fa-user fa-2x" style="color:white; margin:0px 12px 8px 0px;"></mat-icon>
......
......@@ -10,4 +10,12 @@
font-size: 12px;
opacity: 0.5;
}
}
.noAvailableMenu {
text-align: center;
font-size: 14px;
opacity: 0.5;
font-style: italic;
padding: 22px;
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import { IndexingGroupModalComponent } from '../menu/menu-shortcut.component';
import { Router } from '@angular/router';
import { AppService } from '../../service/app.service';
import { PrivilegeService } from '../../service/privileges.service';
import { FunctionsService } from '../../service/functions.service';
@Component({
selector: 'header-right',
......@@ -24,7 +25,7 @@ export class HeaderRightComponent implements OnInit {
hideSearch : boolean = true;
@ViewChild('searchInput', { static: true }) searchInput: MatInput;
@ViewChild('searchInput', { static: false }) searchInput: MatInput;
constructor(
public http: HttpClient,
......@@ -32,6 +33,7 @@ export class HeaderRightComponent implements OnInit {
public dialog: MatDialog,
public appService: AppService,
public headerService: HeaderService,
public functions: FunctionsService,
private privilegeService: PrivilegeService) {}
ngOnInit(): void {
......
......@@ -25,7 +25,7 @@
<span>{{lang.noTemplate}}</span>
</button>
</mat-menu>
<mat-menu #menuEntities="matMenu" [class]="'templateNoteListMenu'">
<mat-menu #menuEntities="matMenu" [class]="'templateNoteListMenu fixedWidth'">
<div
style="z-index:1;position: sticky;top: 0px;text-align: center;font-size: 10px;color: white;background: #135F7F;padding: 5px;font-weight: bold;">
{{lang.entities}}
......@@ -54,7 +54,7 @@
</button>
</mat-form-field>
<div style="overflow: auto;max-height: 75px;">
<div style="font-size: 11px;position: sticky;top: 0px;" [style.background]="upMode ? '#FFEDCC' : 'white'">{{lang.noteVisibleBy}}</div>
<div style="font-size: 11px;position: sticky;top: 0px;" [style.background]="(upMode && entitiesRestriction.length > 0) ? '#FFEDCC' : 'white'">{{lang.noteVisibleBy}}</div>
<span *ngIf="entitiesRestriction.length === 0" class="label label-default noNoteRestriction">{{lang.all}}</span>
<ng-container *ngFor="let entity of entities | sortBy: 'entity_label';let i=index;">
<span *ngIf="entitiesRestriction.indexOf(entity.id) > -1" class="label label-default noteRestriction"
......
......@@ -18,6 +18,13 @@
.mat-menu-content {
padding-top: 0;
padding-bottom: 0;
max-height: 500px;
}
}
::ng-deep.fixedWidth {
.mat-menu-content {
width: 265px;
}
}
......
......@@ -7,6 +7,7 @@ import { HeaderService } from '../../service/header.service';
import { of } from 'rxjs';
import { FunctionsService } from '../../service/functions.service';
import { FormControl } from '@angular/forms';
import { LatinisePipe } from 'ngx-pipes';
@Component({
selector: 'app-note-editor',
......@@ -42,7 +43,8 @@ export class NoteEditorComponent implements OnInit {
public http: HttpClient,
private notify: NotificationService,
public headerService: HeaderService,
public functions: FunctionsService) { }
public functions: FunctionsService,
private latinisePipe: LatinisePipe) { }
async ngOnInit() {
await this.getEntities();
......@@ -63,8 +65,12 @@ export class NoteEditorComponent implements OnInit {
//distinctUntilChanged(),
tap((data: any) => {
if (data.length > 0) {
this.entitiesList = this.entities.filter( (it: any) => {
return (it.entity_label.toLowerCase().includes(data) || it.entity_id.toLowerCase().includes(data));
let filterValue = this.latinisePipe.transform(data.toLowerCase());
this.entitiesList = this.entities.filter( (item: any) => {
return (
this.latinisePipe.transform(item.entity_label.toLowerCase()).includes(filterValue)
|| this.latinisePipe.transform(item.entity_id.toLowerCase()).includes(filterValue)
);
});
} else {
this.entitiesList = this.entities;
......
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