Skip to content

Commit

Permalink
Fixed filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nricciardi committed Jun 4, 2023
1 parent 22ffd69 commit 0bf0336
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 53 deletions.
3 changes: 2 additions & 1 deletion frontend/dist/frontend/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"git_branch": "Git Branch",
"no-task": "No task found",
"invalid-email": "Invalid email",
"committed-at": "Committed at"
"committed-at": "Committed at",
"branch": "Branch"

}
3 changes: 2 additions & 1 deletion frontend/dist/frontend/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"git_branch": "Git Branch",
"no-task": "Nessun task trovato",
"invalid-email": "Email non valida",
"committed-at": "Committed at"
"committed-at": "Committed at",
"branch": "Branch"

}
2 changes: 1 addition & 1 deletion frontend/dist/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
});

</script>
<script src="runtime.0ff8b5c7db2b67dc.js" type="module"></script><script src="polyfills.794d7387aea30963.js" type="module"></script><script src="main.9018a183dc159f19.js" type="module"></script>
<script src="runtime.0ff8b5c7db2b67dc.js" type="module"></script><script src="polyfills.794d7387aea30963.js" type="module"></script><script src="main.115c0c7fdccf5539.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

49 changes: 29 additions & 20 deletions frontend/src/app/page/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<!-- FILTER -->
<app-filter *ngIf="dashboard && dashboard?.tasks"
[filterFields]="['name', 'description']"
[(entities)]="dashboard.tasks">
[entities]="dashboard.tasks"
(entitiesChange)="tasks = $event">
</app-filter>


Expand Down Expand Up @@ -224,7 +225,7 @@ <h3 class="text-center">
data-bs-dismiss="modal"
aria-label="Close"
>
<i data-feather="x"></i>
<i class="bi bi-x"></i>
</button>
</div>
<div class="modal-body">
Expand Down Expand Up @@ -257,7 +258,13 @@ <h3 class="text-center">
</div>
</div>

<div class="row align-items-center">
<div class="row align-items-center justify-content-center">
<div class="col-auto">
<label>
{{ "priority" | translate }}:
</label>
</div>

<div class="col-md-9">
<input
class="form-control"
Expand All @@ -267,23 +274,6 @@ <h3 class="text-center">
formControlName="priority"
/>
</div>

<div class="col-md-3">
<div class="form-check">
<div class="checkbox">
<input
type="checkbox"
id="self-assigned"
class="form-check-input"
[checked]="creationForm.controls['selfAssigned'].value"
formControlName="selfAssigned"
/>
<label for="self-assigned">
{{ "assign-yourself" | translate }}
</label>
</div>
</div>
</div>
</div>

<div class="row mt-2">
Expand All @@ -305,6 +295,25 @@ <h3 class="text-center">
</div>
</div>

<div class="row justify-content-center">
<div class="col-auto">
<div class="form-check">
<div class="checkbox">
<input
type="checkbox"
id="self-assigned"
class="form-check-input"
[checked]="creationForm.controls['selfAssigned'].value"
formControlName="selfAssigned"
/>
<label for="self-assigned">
{{ "assign-yourself" | translate }}
</label>
</div>
</div>
</div>
</div>

</form>

</div>
Expand Down
36 changes: 21 additions & 15 deletions frontend/src/app/page/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ export class DashboardComponent {

dashboard: DashboardModel | null = null;

tasks: TaskModel[] = []; // different by dashboard.task because they may be filtered

onTopTaskIdList: number[] = [];

creationForm = new FormGroup({
name: new FormControl('', [Validators.required]),
description: new FormControl(''),
priority: new FormControl('', [Validators.required]),
selfAssigned: new FormControl(false, [Validators.required])
selfAssigned: new FormControl(false)
});

constructor(private dashboardService: DashboardService, public authService: AuthService, private taskService: TaskService) {
Expand Down Expand Up @@ -113,9 +115,12 @@ export class DashboardComponent {
this.dashboardService.getData().then((response) => {
response.subscribe({
next: (value: DashboardModel | null) => {
if(value) {
if(!!value) {
this.dashboard = value;

// set effective task
this.tasks = [...this.dashboard.tasks];

// set default id index if it is not setted
if(!this.taskStatusIdIndex)
this.taskStatusIdIndex = this.dashboard.default_task_status_id;
Expand Down Expand Up @@ -175,10 +180,10 @@ export class DashboardComponent {

getAllTaskBasedOnStatusId(taskStatusId: number | undefined): TaskModel[] | null {

if(!this.dashboard || !taskStatusId)
if(!this.tasks || !taskStatusId)
return null;

let tasksBasedOnStatusId = this.dashboard!.tasks.filter(task => task !== undefined && task.task_status_id === taskStatusId);
let tasksBasedOnStatusId = this.tasks.filter(task => task !== undefined && task.task_status_id === taskStatusId);

if(!tasksBasedOnStatusId)
return null;
Expand Down Expand Up @@ -246,26 +251,24 @@ export class DashboardComponent {
}

removeTask(taskId: number) {
if(!this.dashboard?.tasks)
if(!this.tasks)
return;

this.dashboard.tasks = this.dashboard.tasks.filter(t => t.id != taskId);
this.tasks = this.tasks.filter(t => t.id != taskId);
}

updateTask(managedTask: UpdateTaskModel) {
if(!this.dashboard?.tasks)
if(!this.tasks)
return;

for (let index = 0; index < this.dashboard.tasks.length; index++) {
const element = this.dashboard.tasks[index];
for (let index = 0; index < this.tasks.length; index++) {
const element = this.tasks[index];

if(element.id == managedTask.target)
this.dashboard.tasks[index] = managedTask.new;
this.tasks[index] = managedTask.new;

}

console.log(this.dashboard.tasks);

}

newTask() {
Expand Down Expand Up @@ -296,7 +299,10 @@ export class DashboardComponent {
response.subscribe({
next: (task) => {

this.creationForm.reset();
if(!!task) {
this.creationForm.reset();

}

// self assign
if(selfAssigned) {
Expand All @@ -309,7 +315,7 @@ export class DashboardComponent {
this.taskService.find(task.id).then((respose) => {
respose.subscribe({
next: (t) => {
this.dashboard?.tasks.push(t);
this.tasks.push(t);

}
})
Expand All @@ -323,7 +329,7 @@ export class DashboardComponent {

} else { // append immediatly task

this.dashboard?.tasks.push(task);
this.tasks.push(task);
}
}
})
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/page/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ <h1 class="auth-title">
class="form-control form-control-xl"
placeholder="Email"
formControlName="email"
[class.is-valid]="loginForm.controls['email'].dirty && loginForm.controls['email'].valid"
[class.is-invalid]="loginForm.controls['email'].dirty && !loginForm.controls['email'].valid"
/>
<div class="form-control-icon">
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/widget/filter/filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class FilterComponent<E> {
}

filter(): void {

if(!this.entitiesBackup || !this.filterFields)
return;

Expand All @@ -74,9 +75,6 @@ export class FilterComponent<E> {
const filteredValue = String((this.filterForm?.controls as any)[filterField].value).toLowerCase();
const associatedEntityValue = String((entity as any)[filterField]).toLowerCase();

console.log(filterField, associatedEntityValue, filteredValue, filteredValue !== "" && associatedEntityValue.includes(filteredValue));


if(filteredValue !== "" && associatedEntityValue.includes(filteredValue))
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/widget/footer/footer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<i class="bi bi-arrow-clockwise"></i>
</button>

<button class="btn icon btn-light"
<!--<button class="btn icon btn-light"
data-bs-toggle="modal"
data-bs-target="#close-app-modal"
type="button">
<i class="bi bi-power"></i>
</button>
</button>-->

<app-dialog-modal [centered]="true"
[target]="'close-app-modal'"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ng-container *ngIf="!!title && !!entities">
<app-filter [filterFields]="filterFields" [(entities)]="entities">
<app-filter [filterFields]="filterFields" [entities]="entities"
(entitiesChange)="entitiesFiltered = $event">
</app-filter>


Expand All @@ -15,7 +16,7 @@


<!-- MANAGE ENTITIES -->
<ng-container *ngFor="let entity of entities">
<ng-container *ngFor="let entity of entitiesFiltered">

<app-manage-entity
[entity]="entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ManageEntitiesComponent<M extends EntityApiService<E>, E extends Ba
@Input("additionalFieldOnCreation") additionalFieldOnCreation: FormField[] = [];

entities?: E[];
entitiesFiltered: E[] = [];

constructor(public utilsService: UtilsService) {}

Expand All @@ -38,6 +39,7 @@ export class ManageEntitiesComponent<M extends EntityApiService<E>, E extends Ba
next: (values: E[]) => {
if(!!values) {
this.entities = values;
this.entitiesFiltered = [...this.entities];
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ <h5 class="modal-title" [id]="target">

</div>

<div class="col-12">
<ng-container *ngIf="!!node && !!node.of_branch">
<strong>{{ "branch" | translate }}</strong>:

<span class="badge bg-light-secondary">
{{ node.of_branch }}
</span>
</ng-container>

</div>

<div class="col-12">
<ng-container *ngIf="!!node && !!node.message">
<strong>{{ "message" | translate }}</strong>: "{{ node.message }}"
Expand Down Expand Up @@ -81,9 +92,9 @@ <h5 class="modal-title" [id]="target">
({{ task.task_status.name }})
</span>

<span class="badge bg-light-secondary" *ngIf="!!task.git_branch">
<!--<span class="badge bg-light-secondary" *ngIf="task.git_branch">
{{ task.git_branch }}
</span>
</span>-->

</li>
</ul>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"git_branch": "Git Branch",
"no-task": "No task found",
"invalid-email": "Invalid email",
"committed-at": "Committed at"
"committed-at": "Committed at",
"branch": "Branch"

}
3 changes: 2 additions & 1 deletion frontend/src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"git_branch": "Git Branch",
"no-task": "Nessun task trovato",
"invalid-email": "Email non valida",
"committed-at": "Committed at"
"committed-at": "Committed at",
"branch": "Branch"

}
2 changes: 1 addition & 1 deletion lib/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class AppManager:

VERSION: str = "1.1.4"
VERSION: str = "1.1.14"
SHUTDOWN_DELAY = 3 # seconds
SHUTDOWN_DELAY_IN_DEBUG_MODE = 600 # seconds

Expand Down
3 changes: 2 additions & 1 deletion lib/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def seeders(self) -> Dict[str, Seeder]:
values=[
("Front-end", "Front-end tasks", "#32a852"),
("Back-end", "Back-end tasks", "#f56342"),
("Documentation", "Documentation tasks", "#f242f5")
("Documentation", "Documentation tasks", "#f242f5"),
("Database", "Database manipulation tasks", "#f5a142"),
], cols=("name", "description", "hex_color")),

self.role_table_name: Seeder(table=self.role_table_name,
Expand Down

0 comments on commit 0bf0336

Please sign in to comment.