-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify OTAC Modal to handle durations (#193)
* Modify OTAC Modal to handle durations * Remove combinations
- Loading branch information
Showing
7 changed files
with
189 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export type OTAC = { | ||
name: string; | ||
user?: string; | ||
redeemed_timestamp?: string | ||
} | ||
name: string; | ||
user?: string; | ||
redeemed_timestamp?: string; | ||
max_duration?: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 109 additions & 49 deletions
158
src/app/event/otacmanagement/otacmanagement.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,113 @@ | ||
<clr-modal [(clrModalOpen)]="open" [clrModalSize]="'xl'" [clrModalClosable]="false"> | ||
<h3 class="modal-title" *ngIf="open"> | ||
OTACs for {{ currentScheduledEvent.event_name }} | ||
</h3> | ||
<div class="modal-body"> | ||
<form clrForm [formGroup]="amountInputForm" class="flexbox" *rbac="['scheduledevents.update']"> | ||
<div>New OTACs:</div> | ||
<clr-input-container class="input-container"> | ||
<input formControlName="amountInput" type="number" clrInput name="amountNewOtacsInput" | ||
[(ngModel)]="amountNewOtacs" /> | ||
<clr-control-error>Input must be a positive Number</clr-control-error> | ||
</clr-input-container> | ||
<button [disabled]="!amountInputForm.valid" type="button" class="btn btn-primary" (click)="createOtacs()"> | ||
generate | ||
</button> | ||
</form> | ||
<clr-modal | ||
[(clrModalOpen)]="open" | ||
[clrModalSize]="'xl'" | ||
[clrModalClosable]="false" | ||
> | ||
<h3 class="modal-title" *ngIf="open"> | ||
OTACs for {{ currentScheduledEvent.event_name }} | ||
</h3> | ||
<div class="modal-body"> | ||
<form | ||
clrForm | ||
[formGroup]="amountInputForm" | ||
class="flexbox" | ||
*rbac="['scheduledevents.update']" | ||
> | ||
<div>New OTACs:</div> | ||
<clr-input-container class="input-container"> | ||
<label class="otac-label">Count</label> | ||
<input | ||
formControlName="amountInput" | ||
type="number" | ||
clrInput | ||
name="amountNewOtacsInput" | ||
[(ngModel)]="amountNewOtacs" | ||
/> | ||
<clr-control-error>Input must be a positive Number</clr-control-error> | ||
</clr-input-container> | ||
|
||
<div class="datagrid-container"> | ||
<clr-datagrid> | ||
<clr-dg-column [clrDgField]="'status'" [clrDgSortOrder]="descSort">Status</clr-dg-column> | ||
<clr-dg-column>OTAC</clr-dg-column> | ||
<clr-dg-column [clrDgField]="'userEmail'">Claimed by</clr-dg-column> | ||
<clr-dg-column>Claimed at</clr-dg-column> | ||
<clr-dg-column *rbac="['scheduledevents.update']">Delete</clr-dg-column> | ||
<clr-input-container class="input-container"> | ||
<label class="otac-label">Duration</label> | ||
<input | ||
formControlName="duration" | ||
type="text" | ||
clrInput | ||
name="duration" | ||
placeholder="e.g. 1d, 24h, 60m" | ||
title="Duration" | ||
[(ngModel)]="duration" | ||
/> | ||
<clr-control-error | ||
>Input must be a valid duration consisting of a number followed by | ||
(d,h,m).</clr-control-error | ||
> | ||
</clr-input-container> | ||
<button | ||
[disabled]="!amountInputForm.valid" | ||
type="button" | ||
class="btn btn-primary" | ||
(click)="createOtacs()" | ||
> | ||
generate | ||
</button> | ||
</form> | ||
|
||
<clr-dg-row *clrDgItems="let otac of otacs"> | ||
<clr-dg-cell> | ||
<span class="badge badge-success" *ngIf="otac.status == 'free'">free</span> | ||
<span class="badge badge-info" *ngIf="otac.status == 'taken'">taken</span> | ||
</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.name }}</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.userEmail }}</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.redeemed_timestamp }}</clr-dg-cell> | ||
<clr-dg-cell *rbac="['scheduledevents.update']"> | ||
<button type="button" class="btn btn-warning-outline" (click)="deleteOtac(otac)"> | ||
Delete | ||
</button> | ||
</clr-dg-cell> | ||
</clr-dg-row> | ||
<div class="datagrid-container"> | ||
<clr-datagrid> | ||
<clr-dg-column [clrDgField]="'status'" [clrDgSortOrder]="descSort" | ||
>Status</clr-dg-column | ||
> | ||
<clr-dg-column>OTAC</clr-dg-column> | ||
<clr-dg-column [clrDgField]="'userEmail'">Claimed by</clr-dg-column> | ||
<clr-dg-column>Claimed at</clr-dg-column> | ||
<clr-dg-column>Max. Duration</clr-dg-column> | ||
<clr-dg-column *rbac="['scheduledevents.update']">Delete</clr-dg-column> | ||
|
||
<clr-dg-footer>{{ getOverallInfo() }}</clr-dg-footer> | ||
</clr-datagrid> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="exportCSV()"> | ||
Export to csv | ||
</button> | ||
<button type="button" class="btn btn-flat-primary" (click)="close()"> | ||
Close | ||
</button> | ||
<clr-dg-row *clrDgItems="let otac of otacs"> | ||
<clr-dg-cell> | ||
<span class="badge badge-success" *ngIf="otac.status == 'free'" | ||
>free</span | ||
> | ||
<span class="badge badge-info" *ngIf="otac.status == 'taken'" | ||
>taken</span | ||
> | ||
<span | ||
class="badge badge-danger" | ||
*ngIf="otac.status == 'out-of-time'" | ||
>out-of-time</span | ||
> | ||
</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.name }}</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.userEmail }}</clr-dg-cell> | ||
<clr-dg-cell>{{ otac.redeemed_timestamp }}</clr-dg-cell> | ||
<clr-dg-cell *ngIf="hasMaxDuration(otac)" | ||
><clr-icon shape="clock"></clr-icon> | ||
{{ otac.max_duration }}</clr-dg-cell | ||
> | ||
<clr-dg-cell *ngIf="!hasMaxDuration(otac)" | ||
>Until Event ends</clr-dg-cell | ||
> | ||
<clr-dg-cell *rbac="['scheduledevents.update']"> | ||
<button | ||
type="button" | ||
class="btn btn-warning-outline" | ||
(click)="deleteOtac(otac)" | ||
> | ||
Delete | ||
</button> | ||
</clr-dg-cell> | ||
</clr-dg-row> | ||
|
||
<clr-dg-footer>{{ getOverallInfo() }}</clr-dg-footer> | ||
</clr-datagrid> | ||
</div> | ||
</clr-modal> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="exportCSV()"> | ||
Export to csv | ||
</button> | ||
<button type="button" class="btn btn-flat-primary" (click)="close()"> | ||
Close | ||
</button> | ||
</div> | ||
</clr-modal> |
30 changes: 17 additions & 13 deletions
30
src/app/event/otacmanagement/otacmanagement.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
.datagrid-container { | ||
height: 60vh; | ||
max-height: 60vh | ||
height: 60vh; | ||
max-height: 60vh; | ||
} | ||
|
||
.datagrid-container clr-datagrid { | ||
max-height: 100%; | ||
max-height: 100%; | ||
} | ||
|
||
.flexbox { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-items: center; | ||
height: fit-content; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-items: center; | ||
height: fit-content; | ||
width: 100%; | ||
} | ||
|
||
.input-container { | ||
width: min-content; | ||
padding-right: 2vw; | ||
width: min-content; | ||
padding-right: 2vw; | ||
} | ||
|
||
.flexbox * { | ||
margin: 0; | ||
} | ||
margin: 0; | ||
} | ||
|
||
.otac-label.clr-col-md-2 { | ||
max-width: fit-content; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters