Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
217fbb8
feat: TT-208 add new column in activity-list
thegreatyamori Apr 19, 2021
6c1c06f
feat: TT-208 add switch status button in column
thegreatyamori Apr 19, 2021
dc10fcf
feat: TT-208 remove delete button & assign openmodal to switch
thegreatyamori Apr 20, 2021
fb37b3b
feat: TT-208 connect switch btn with ngrx flux
thegreatyamori Apr 20, 2021
f0275f8
feat: TT-208 update ngrx delete flux
thegreatyamori Apr 20, 2021
e8ee50f
feat: TT-208 show active activities in entry & details fields
thegreatyamori Apr 21, 2021
a62c980
feat: TT-208 change ui-switch to button
thegreatyamori Apr 22, 2021
5c19c86
fix: TT-208 display the required activities when clicking on time en…
thegreatyamori Apr 26, 2021
a76051c
Merge branch 'master' into TT-208-don't-allow-deleting-activities
thegreatyamori Apr 26, 2021
aa698ee
feat: TT-208 add new column in activity-list
thegreatyamori Apr 26, 2021
5ca9a8f
feat: TT-208 add switch status button in column
thegreatyamori Apr 26, 2021
17d5acd
feat: TT-208 remove delete button & assign openmodal to switch
thegreatyamori Apr 26, 2021
90742ad
feat: TT-208 connect switch btn with ngrx flux
thegreatyamori Apr 26, 2021
4977dff
feat: TT-208 update ngrx delete flux
thegreatyamori Apr 26, 2021
1d0107d
feat: TT-208 show active activities in entry & details fields
thegreatyamori Apr 21, 2021
5808250
feat: TT-208 change ui-switch to button
thegreatyamori Apr 22, 2021
286033c
fix: TT-208 display the required activities when clicking on time en…
thegreatyamori Apr 26, 2021
3a5e107
feat: TT-208 rebase on latest master commit
thegreatyamori Apr 26, 2021
1c9ee96
fix: TT-208 merging conflicts
thegreatyamori Apr 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: TT-208 remove delete button & assign openmodal to switch
  • Loading branch information
thegreatyamori committed Apr 20, 2021
commit dc10fcfdf3ade2894b6e35d66c43d2f01bceb777
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@
<button type="button" class="btn btn-sm btn-primary" (click)="updateActivity(activity.id)">
<i class="fa fa-pencil fa-xs"></i>
</button>
<button
type="button"
class="btn btn-sm btn-danger ml-2"
data-toggle="modal"
data-target="#deleteModal"
(click)="openModal(activity)"
>
<i class="fas fa-trash-alt fa-xs"></i>
</button>
</td>
<td class="col-2 text-center">
<ui-switch
size="small"
(change)="switchStatus('active')"
data-toggle="modal"
data-target="#deleteModal"
[checked]="activity.status === 'active'"
(valueChange)="switchStatus($event, activity)"
[beforeChange]="OnSwitch(activity)"
></ui-switch>
</td>
</tr>
Expand All @@ -46,7 +40,7 @@
tabindex="-1"
role="dialog"
aria-hidden="true"
[title]="'Delete Activity'"
[title]="'Archive Activity'"
[body]="message"
(closeModalEvent)="deleteActivity()"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { Component, OnInit } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators';
import { getIsLoading } from 'src/app/modules/activities-management/store/activity-management.selectors';
import { Activity } from '../../../shared/models';
import { allActivities } from '../../store';
import { DeleteActivity, LoadActivities, SetActivityToEdit } from './../../store/activity-management.actions';
import { ActivityState } from './../../store/activity-management.reducers';


@Component({
selector: 'app-activity-list',
templateUrl: './activity-list.component.html',
styleUrls: ['./activity-list.component.scss'],
})
export class ActivityListComponent implements OnInit {
constructor(private store: Store<ActivityState>) {
this.isLoading$ = store.pipe(delay(0), select(getIsLoading));
}
activities: Activity[] = [];
showModal = false;
activityToDelete: Activity;
message: string;
idToDelete: string;
isLoading$: Observable<boolean>;
constructor(private store: Store<ActivityState>) {
this.isLoading$ = store.pipe(delay(0), select(getIsLoading));
}

ngOnInit() {
this.store.dispatch(new LoadActivities());
Expand All @@ -35,8 +34,9 @@ export class ActivityListComponent implements OnInit {
}

deleteActivity() {
this.store.dispatch(new DeleteActivity(this.idToDelete));
this.showModal = true;
// this.store.dispatch(new DeleteActivity(this.idToDelete));
console.log('despachado el evento');
this.showModal = false;
}

updateActivity(activityId: string) {
Expand All @@ -45,15 +45,26 @@ export class ActivityListComponent implements OnInit {

openModal(item: Activity) {
this.idToDelete = item.id;
this.message = `Are you sure you want to delete ${item.name}?`;
this.message = `Are you sure you want to archive activity ${item.name}?`;
this.showModal = true;
console.log(`Despliegue del modal para id: ${item.id}`);
}

switchStatus(evt: boolean, item: Activity): void {
if (!evt) {
// FIXME: Si el usuario selecciona cancelar, se produce la animación de cambio
// del switch
this.openModal(item);
} else {
this.showModal = false;
// TODO: dispatch para actualizar la operacion
// this.store.dispatch(new SetToTrueActivity());
}
}

switchStatus(state: string): void {
// this.store.dispatch(
// user.groups.includes(groupName)
// ? new RemoveUserFromGroup(user.id, groupName)
// : new AddUserToGroup(user.id, groupName)
// );
OnSwitch(item: Activity): Observable<boolean> {
// FIXME: OnBeforeChange debería ser un evento que traiga el estado del switch
// para poder realizar una acción antes de que el estado cambie.
return of(true);
}
}