app-template.component.html
· 5.4 KiB · HTML
Bruto
<div class="card">
<p-toast></p-toast>
<p-confirmDialog></p-confirmDialog>
<div class="flex justify-content-between align-items-center mb-3 flex-wrap">
<h2 class="text-xxl col-12 sm:col" id="page-heading" data-cy="AppTemplateHeading">
<span>App Templates</span>
</h2>
<button pButton pRipple label="Create a new app template" icon="pi pi-plus" class="col-6 xl:col-1 p-button sm:mr-2 xl:ml-auto w-auto"
(click)="showDialog()" [class]="layoutService.config.colorScheme === 'light' ? '' : 'p-button-text'"></button>
</div>
<p-table [value]="templates" [rows]="10" [paginator]="true"
[globalFilterFields]="['name','description','category']"
[tableStyle]="{'min-width': '75rem'}"
[loading]="isLoading"
[sortField]="predicate"
[sortOrder]="ascending ? 1 : -1"
(onSort)="onSort($event)">
<ng-template pTemplate="header">
<tr>
<th pSortableColumn="name">Name <p-sortIcon field="name"></p-sortIcon></th>
<th pSortableColumn="description">Description <p-sortIcon field="description"></p-sortIcon></th>
<th pSortableColumn="category" class="whitespace-nowrap">Category <p-sortIcon field="category"></p-sortIcon></th>
<th>Actions</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-template>
<tr>
<td>{{ template.name }}</td>
<td>{{ template.description }}</td>
<td>{{ template.category }}</td>
<td class="flex">
<button pButton pRipple
icon="pi pi-eye"
class="p-button-rounded p-button-text"
(click)="showDialog(template)"
pTooltip="View/Edit">
</button>
<button pButton pRipple
icon="pi pi-trash"
class="p-button-rounded p-button-text p-button-danger"
(click)="confirmDelete(template)"
pTooltip="Delete">
</button>
</td>
</tr>
</ng-template>
<ng-template pTemplate="emptymessage">
<tr>
<td colspan="6">No app templates found.</td>
</tr>
</ng-template>
</p-table>
<!-- View/Edit Dialog -->
<p-dialog [(visible)]="displayDialog" [style]="{width: '75%'}"
[header]="isNewTemplate ? 'Create App Template' : 'View App Template'"
[modal]="true">
<form [formGroup]="templateForm" (ngSubmit)="save()">
<div class="grid p-fluid">
<div class="col-12 mb-3">
<span class="p-float-label">
<input pInputText id="name" formControlName="name"/>
<label for="name">Name</label>
</span>
<small class="p-error" *ngIf="templateForm.get('name')?.hasError('required') &&
templateForm.get('name')?.touched">
Name is required
</small>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<textarea rows="3" pInputTextarea id="description" formControlName="description"></textarea>
<label for="description">Description</label>
</span>
<small class="p-error" *ngIf="templateForm.get('description')?.hasError('required') &&
templateForm.get('description')?.touched">
Description is required
</small>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<textarea rows="20" pInputTextarea id="longDescription" formControlName="longDescription"></textarea>
<label for="description">Long Description</label>
</span>
<small class="p-error" *ngIf="templateForm.get('longDescription')?.hasError('required') &&
templateForm.get('longDescription')?.touched">
Long Description is required
</small>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<input pInputText id="category" formControlName="category"/>
<label for="category">Category</label>
</span>
<small class="p-error" *ngIf="templateForm.get('cid')?.hasError('required') &&
templateForm.get('cid')?.touched">
Category is required
</small>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<input pInputText id="icon" formControlName="icon"/>
<label for="icon">Icon URL</label>
</span>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<textarea pInputTextarea id="template" [rows]="20" formControlName="template">
</textarea>
<label for="template">Template</label>
</span>
</div>
<div class="col-12 mb-3">
<span class="p-float-label">
<p-inputNumber id="zorder" mode="decimal" inputId="zorder"
[step]="1" [min]="0" [max]="1000"
formControlName="zorder" [showButtons]="true"></p-inputNumber>
<label for="zorder">Order</label>
</span>
</div>
</div>
<div class="flex justify-content-end mt-4">
<button pButton type="button" label="Close"
class="p-button-secondary mr-2" (click)="hideDialog()"></button>
<button pButton type="submit" label="Save"
[disabled]="!templateForm.valid"></button>
</div>
</form>
</p-dialog>
</div>
| 1 | <div class="card"> |
| 2 | <p-toast></p-toast> |
| 3 | <p-confirmDialog></p-confirmDialog> |
| 4 | <div class="flex justify-content-between align-items-center mb-3 flex-wrap"> |
| 5 | <h2 class="text-xxl col-12 sm:col" id="page-heading" data-cy="AppTemplateHeading"> |
| 6 | <span>App Templates</span> |
| 7 | </h2> |
| 8 | <button pButton pRipple label="Create a new app template" icon="pi pi-plus" class="col-6 xl:col-1 p-button sm:mr-2 xl:ml-auto w-auto" |
| 9 | (click)="showDialog()" [class]="layoutService.config.colorScheme === 'light' ? '' : 'p-button-text'"></button> |
| 10 | </div> |
| 11 | <p-table [value]="templates" [rows]="10" [paginator]="true" |
| 12 | [globalFilterFields]="['name','description','category']" |
| 13 | [tableStyle]="{'min-width': '75rem'}" |
| 14 | [loading]="isLoading" |
| 15 | [sortField]="predicate" |
| 16 | [sortOrder]="ascending ? 1 : -1" |
| 17 | (onSort)="onSort($event)"> |
| 18 | |
| 19 | <ng-template pTemplate="header"> |
| 20 | <tr> |
| 21 | <th pSortableColumn="name">Name <p-sortIcon field="name"></p-sortIcon></th> |
| 22 | <th pSortableColumn="description">Description <p-sortIcon field="description"></p-sortIcon></th> |
| 23 | <th pSortableColumn="category" class="whitespace-nowrap">Category <p-sortIcon field="category"></p-sortIcon></th> |
| 24 | <th>Actions</th> |
| 25 | </tr> |
| 26 | </ng-template> |
| 27 | |
| 28 | |
| 29 | <ng-template pTemplate="body" let-template> |
| 30 | <tr> |
| 31 | <td>{{ template.name }}</td> |
| 32 | <td>{{ template.description }}</td> |
| 33 | <td>{{ template.category }}</td> |
| 34 | <td class="flex"> |
| 35 | <button pButton pRipple |
| 36 | icon="pi pi-eye" |
| 37 | class="p-button-rounded p-button-text" |
| 38 | (click)="showDialog(template)" |
| 39 | pTooltip="View/Edit"> |
| 40 | </button> |
| 41 | |
| 42 | <button pButton pRipple |
| 43 | icon="pi pi-trash" |
| 44 | class="p-button-rounded p-button-text p-button-danger" |
| 45 | (click)="confirmDelete(template)" |
| 46 | pTooltip="Delete"> |
| 47 | </button> |
| 48 | </td> |
| 49 | </tr> |
| 50 | </ng-template> |
| 51 | |
| 52 | <ng-template pTemplate="emptymessage"> |
| 53 | <tr> |
| 54 | <td colspan="6">No app templates found.</td> |
| 55 | </tr> |
| 56 | </ng-template> |
| 57 | </p-table> |
| 58 | |
| 59 | <!-- View/Edit Dialog --> |
| 60 | <p-dialog [(visible)]="displayDialog" [style]="{width: '75%'}" |
| 61 | [header]="isNewTemplate ? 'Create App Template' : 'View App Template'" |
| 62 | [modal]="true"> |
| 63 | <form [formGroup]="templateForm" (ngSubmit)="save()"> |
| 64 | <div class="grid p-fluid"> |
| 65 | <div class="col-12 mb-3"> |
| 66 | <span class="p-float-label"> |
| 67 | <input pInputText id="name" formControlName="name"/> |
| 68 | <label for="name">Name</label> |
| 69 | </span> |
| 70 | <small class="p-error" *ngIf="templateForm.get('name')?.hasError('required') && |
| 71 | templateForm.get('name')?.touched"> |
| 72 | Name is required |
| 73 | </small> |
| 74 | </div> |
| 75 | |
| 76 | <div class="col-12 mb-3"> |
| 77 | <span class="p-float-label"> |
| 78 | <textarea rows="3" pInputTextarea id="description" formControlName="description"></textarea> |
| 79 | <label for="description">Description</label> |
| 80 | </span> |
| 81 | <small class="p-error" *ngIf="templateForm.get('description')?.hasError('required') && |
| 82 | templateForm.get('description')?.touched"> |
| 83 | Description is required |
| 84 | </small> |
| 85 | </div> |
| 86 | |
| 87 | <div class="col-12 mb-3"> |
| 88 | <span class="p-float-label"> |
| 89 | <textarea rows="20" pInputTextarea id="longDescription" formControlName="longDescription"></textarea> |
| 90 | <label for="description">Long Description</label> |
| 91 | </span> |
| 92 | <small class="p-error" *ngIf="templateForm.get('longDescription')?.hasError('required') && |
| 93 | templateForm.get('longDescription')?.touched"> |
| 94 | Long Description is required |
| 95 | </small> |
| 96 | </div> |
| 97 | |
| 98 | <div class="col-12 mb-3"> |
| 99 | <span class="p-float-label"> |
| 100 | <input pInputText id="category" formControlName="category"/> |
| 101 | <label for="category">Category</label> |
| 102 | </span> |
| 103 | <small class="p-error" *ngIf="templateForm.get('cid')?.hasError('required') && |
| 104 | templateForm.get('cid')?.touched"> |
| 105 | Category is required |
| 106 | </small> |
| 107 | </div> |
| 108 | |
| 109 | <div class="col-12 mb-3"> |
| 110 | <span class="p-float-label"> |
| 111 | <input pInputText id="icon" formControlName="icon"/> |
| 112 | <label for="icon">Icon URL</label> |
| 113 | </span> |
| 114 | </div> |
| 115 | |
| 116 | <div class="col-12 mb-3"> |
| 117 | <span class="p-float-label"> |
| 118 | <textarea pInputTextarea id="template" [rows]="20" formControlName="template"> |
| 119 | </textarea> |
| 120 | <label for="template">Template</label> |
| 121 | </span> |
| 122 | </div> |
| 123 | |
| 124 | <div class="col-12 mb-3"> |
| 125 | <span class="p-float-label"> |
| 126 | <p-inputNumber id="zorder" mode="decimal" inputId="zorder" |
| 127 | [step]="1" [min]="0" [max]="1000" |
| 128 | formControlName="zorder" [showButtons]="true"></p-inputNumber> |
| 129 | <label for="zorder">Order</label> |
| 130 | </span> |
| 131 | </div> |
| 132 | </div> |
| 133 | |
| 134 | <div class="flex justify-content-end mt-4"> |
| 135 | <button pButton type="button" label="Close" |
| 136 | class="p-button-secondary mr-2" (click)="hideDialog()"></button> |
| 137 | |
| 138 | <button pButton type="submit" label="Save" |
| 139 | [disabled]="!templateForm.valid"></button> |
| 140 | </div> |
| 141 | </form> |
| 142 | </p-dialog> |
| 143 | </div> |
| 144 |