Skip to content
Snippets Groups Projects
attachment-page.component.html 15.7 KiB
Newer Older
<div class="attach-container">
    <div class="example-loading-shade" *ngIf="sendingData">
        <mat-spinner></mat-spinner>
    </div>
    <h1 mat-dialog-title>
        <span *ngIf="!loading" style="flex: 1;" [title]="attachment.title.value">
            <ng-container *ngIf="attachment.chrono.value !== null">
                {{attachment.chrono.value}} -
            </ng-container>
            {{attachment.title.value | shorten: 50: '...'}}
        </span>
        <button [title]="lang.close" mat-icon-button (click)="dialogRef.close();">
            <mat-icon class="fa fa-times"></mat-icon>
        </button></h1>
    <mat-dialog-content class="attach-content">
Alex ORLUC's avatar
Alex ORLUC committed
            <ng-container *ngIf="!loading">
                    <div class="attachment-form col-md-3 col-sm-12">
                        <div *ngIf="editMode" class="attachment-form-item">
                            <mat-slide-toggle [checked]="newVersion" color="primary"
                                (change)="newVersion = !newVersion;">{{lang.newVersion}}</mat-slide-toggle>
                        </div>
                        <div *ngIf="newVersion" class="attachment-form-item">
                            <div class="alert-message alert-message-danger" role="alert"
                                [innerHTML]="lang.mustEditDocument"></div>
                        <div class="attachment-form-item">
                            <mat-form-field class="input-form">
                                <input matInput placeholder="{{lang.status}}" [formControl]="attachment['status']"
                                    [value]="lang['attachment_'+attachment['status'].value]">
                            </mat-form-field>
                            <div class="fieldState">
                                <i class="fas fa-asterisk noMandatory"></i>
                            </div>
                        </div>
                        <div class="attachment-form-item">
                            <plugin-select-search [label]="lang.type" [placeholderLabel]="lang.type"
                                [formControlSelect]="attachment['type']" [datas]="attachmentsTypes"
                                (afterSelected)="getAttachType($event)" style="width:100%;">
                            </plugin-select-search>
                            <div class="fieldState">
                                <i class="fas fa-asterisk fieldRequired"
                                    *ngIf="attachment['type'].hasError('required') && attachment['type'].untouched"></i>
                                <i class="fas fa-exclamation-triangle fieldError"
                                    *ngIf="attachment['type'].touched && attachment['type'].hasError('required')"></i>
                                <i class="fas fa-check fieldFull"
                                    *ngIf="attachment['type'].valid && !isEmptyField(attachment['type'])"></i>
                        </div>
                        <div class="attachment-form-item">
                            <mat-form-field class="input-form">
                                <input matInput placeholder="{{lang.subject}}" [formControl]="attachment['title']">
                            </mat-form-field>
                            <div class="fieldState">
                                <i class="fas fa-asterisk fieldRequired"
                                    *ngIf="attachment['title'].hasError('required') && attachment['title'].untouched"></i>
                                <i class="fas fa-exclamation-triangle fieldError"
                                    *ngIf="attachment['title'].touched && attachment['title'].hasError('required')"></i>
                                <i class="fas fa-check fieldFull"
                                    *ngIf="attachment['title'].valid && !isEmptyField(attachment['title'])"></i>
                        <div class="attachment-form-item" *ngIf="sendMassMode" style="display: block;">
                            <div class="alert alert-info" role="alert" [innerHTML]="lang.mailingMsg"></div>
                        </div>
                        <div class="attachment-form-item" *ngIf="!sendMassMode">
                            <app-contact-autocomplete [control]="attachment['recipient']" style="width:100%;" [singleMode]="true">
                            </app-contact-autocomplete>
                            <div class="fieldState">
                                <i class="fas fa-asterisk noMandatory"></i>
                            </div>
                        <div class="attachment-form-item" *ngIf="attachment['signedResponse'].value !== undefined">
                            <mat-form-field class="input-form">
                                <input matInput placeholder="{{lang.signedAlt}}" [formControl]="attachment['signDate']"
                                    [value]="attachment['signDate'].value | timeAgo : 'full'">
                            </mat-form-field>
                            <div class="fieldState">
                                <i class="fas fa-asterisk noMandatory"></i>
                            </div>
                        <div class="attachment-form-item" *ngIf="attachment['signedResponse'].value !== undefined">
                            <mat-form-field class="input-form">
                                <input matInput placeholder="{{lang.signedAlt}} {{lang.by}}"
                                    [formControl]="attachment['signatory']">
                            </mat-form-field>
                            <div class="fieldState">
                                <i class="fas fa-asterisk noMandatory"></i>
                            </div>
                        </div>
                        <mat-expansion-panel>
                            <mat-expansion-panel-header>
                                <mat-panel-title>
                                    {{lang.othersInfos}}
                                </mat-panel-title>
                            </mat-expansion-panel-header>
                            <div class="attachment-form-item">
                                <mat-form-field class="input-form">
                                    <input matInput placeholder="{{lang.created}}"
                                        [formControl]="attachment['creationDate']"
                                        [value]="attachment['creationDate'].value | timeAgo : 'full'">
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"></i>
                                </div>
                            </div>
                            <div class="attachment-form-item">
                                <mat-form-field class="input-form">
                                    <input matInput placeholder="{{lang.created}} {{lang.by}}"
                                        [formControl]="attachment['typistLabel']">
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"></i>
                                </div>
                            </div>
Alex ORLUC's avatar
Alex ORLUC committed
                            <div class="attachment-form-item" *ngIf="attachment['modificationDate'].value !== null">
                                <mat-form-field class="input-form">
                                    <input matInput placeholder="{{lang.modified}}"
                                        [formControl]="attachment['modificationDate']"
                                        [value]="attachment['modificationDate'].value | timeAgo : 'full'">
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"></i>
                                </div>
                            </div>
Alex ORLUC's avatar
Alex ORLUC committed
                            <div class="attachment-form-item" *ngIf="attachment['modificationDate'].value !== null">
                                <mat-form-field class="input-form">
                                    <input matInput placeholder="{{lang.modified}} {{lang.by}}"
                                        [formControl]="attachment['modifiedBy']">
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"></i>
                                </div>
                            </div>
                            <div class="attachment-form-item">
                                <mat-form-field class="input-form">
                                    <input matInput placeholder="{{lang.version}}"
                                        [formControl]="attachment['relation']"
                                        [value]="lang.version + ' ' + attachment.relation.value">
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"></i>
                                </div>
                            </div>
                            <div class="attachment-form-item">
                                <mat-form-field class="input-form" (click)="picker.open()" style="cursor:pointer;">
                                    <input [formControl]="attachment['validationDate']" matInput
                                        [matDatepicker]="picker" [placeholder]="lang.expectedReturnDate" [min]="now"
                                        readonly style="cursor:pointer;">
                                    <mat-datepicker-toggle matSuffix [for]="picker"
                                        *ngIf="!attachment['validationDate'].value">
                                    </mat-datepicker-toggle>
                                    <mat-datepicker [touchUi]="appService.getViewMode()" #picker></mat-datepicker>
                                    <button mat-button color="warn" matSuffix mat-icon-button
                                        *ngIf="attachment['validationDate'].value && !attachment['validationDate'].disabled"
                                        (click)="$event.stopPropagation();attachment['validationDate'].reset();"
                                        [title]="lang.eraseValue">
                                        <mat-icon color="warn" class="fa fa-calendar-times">
                                        </mat-icon>
                                    </button>
                                </mat-form-field>
                                <div class="fieldState">
                                    <i class="fas fa-asterisk noMandatory"
                                        *ngIf="attachment['validationDate'].valid && isEmptyField(attachment['validationDate'])"></i>
                                    <i class="fas fa-check fieldFull"
                                        *ngIf="attachment['validationDate'].valid && !isEmptyField(attachment['validationDate'])"></i>
                                </div>
                            </div>
                        </mat-expansion-panel>
                </ng-container>
                <mat-tab-group [selectedIndex]="1" class="pjList" *ngIf="!loading" animationDuration="0" style="height: 100%">
Alex ORLUC's avatar
Alex ORLUC committed
                        <mat-tab label="Document principal" *ngIf="attachment.res_id_master !== null">
                            <ng-template matTabContent>
                                <app-document-viewer #appDocumentViewer style="display:block;height:100%;width:100%;overflow: auto;" [editMode]="false"
Alex ORLUC's avatar
Alex ORLUC committed
                                    [resId]="attachment.resIdMaster.value" [title]="'Document principal'">
                                </app-document-viewer>
                            </ng-template>
                        </mat-tab>
                        <mat-tab *ngIf="attachment.status.value === 'SIGN'">
                            <ng-template mat-tab-label>
                                <span style="color:green">{{lang.signedAttachment}}</span>
                            </ng-template>
                            <app-document-viewer #appDocumentViewer style="display:block;height:100%;width:100%;overflow: auto;" [editMode]="false"
Alex ORLUC's avatar
Alex ORLUC committed
                                [resId]="attachment.signedResponse.value" [mode]="'attachment'"
                                [title]="attachment.chrono.value + ' - ' + attachment.title.value + ' (' + lang.signed + ')'">
                            </app-document-viewer>
Alex ORLUC's avatar
Alex ORLUC committed
                        </mat-tab>
                        <mat-tab>
                            <ng-template mat-tab-label>
                                <span style="color:#135f7f">{{lang.attachment}}</span>
                            </ng-template>
                            <app-document-viewer #appAttachmentViewer style="display:block;height:100%;width:100%;overflow: auto;" [editMode]="editMode"
Alex ORLUC's avatar
Alex ORLUC committed
                                [resId]="data.resId" [resIdMaster]="attachment['resIdMaster'].value" [mode]="'attachment'"
                                [format]="attachment['format'].value" [attachType]="attachment['type'].value" [infoPanel]="snavLeft"
                                (triggerEvent)="setDatasViewer($event)"
                                [title]="attachment.chrono.value + ' - ' + attachment.title.value">
                            </app-document-viewer>
Alex ORLUC's avatar
Alex ORLUC committed
                        </mat-tab>
                        <mat-tab label="{{lang.attachment}} ({{lang.version}} {{version.relation}})"
                            *ngFor="let version of versions">
                            <ng-template matTabContent>
                                <app-document-viewer #appDocumentViewer style="display:block;height:100%;width:100%;overflow: auto;" [editMode]="false"
Alex ORLUC's avatar
Alex ORLUC committed
                                    [resId]="version.resId" [mode]="'attachment'" [format]="attachment['format'].value"
                                    [title]="attachment.chrono.value + ' - ' + attachment.title.value + ' (' + version.relation + ')'">
                                </app-document-viewer>
                            </ng-template>
    
                        </mat-tab>
                    </mat-tab-group>
    </mat-dialog-content>
    <div mat-dialog-actions class="actions">
        <button mat-raised-button color="primary" *ngIf="!newVersion" (click)="updateAttachment()"
            [disabled]="!loading && (!editMode || !attachFormGroup.valid)">{{lang.validate}}</button>
        <button mat-raised-button color="primary" *ngIf="!newVersion && sendMassMode && !loading" (click)="updateAttachment('mailing')"
            [disabled]="!loading && (!editMode || !attachFormGroup.valid)">{{lang.mailing}}</button>
        <button mat-raised-button color="primary" *ngIf="newVersion" (click)="createNewVersion()"
            [disabled]="!editMode || !isEditing()">{{lang.createNewVersion}}</button>
        <button mat-raised-button color="primary" *ngIf="newVersion && sendMassMode && !loading" (click)="createNewVersion('mailing')"
            [disabled]="!editMode || !isEditing()">{{lang.mailing}}</button>
        <button mat-raised-button color="warn" *ngIf=" !loading && attachment.status.value === 'SIGN' && (privilegeService.hasCurrentUserPrivilege('sign_document') || this.headerService.user.id == attachment.typist.value)"
            (click)="deleteSignedVersion()">{{lang.deleteSignedVersion}}</button>
        <button mat-raised-button mat-button [disabled]="loading" (click)="closeModal()">{{lang.close}}</button>