Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
feat(projects): Separate load from show activities
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadalfy committed Feb 1, 2020
1 parent 409d5ff commit fa2bea3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class Projects extends Base {
<td data-key="group" data-value="${group?.id}">${group?.name || '-'}</td>
<td data-key="date" data-value="${Date.parse(project.last_activity_at)}">${timeAgo.format(Date.parse(project.last_activity_at))}</td>
<td class="listing__actions">
<button @click=${()=> {this.showProjectActivities(project.id, project.name)}}>Show Activity</button>
<button title="Load Activities" @click=${()=> {this.loadProjectActivities(project.id)}}>Load</button>
<button title="Display Activities" @click=${()=> {this.showProjectActivities(project.id, project.name)}}>Display</button>
</td>
</tr>
`);
Expand Down Expand Up @@ -102,13 +103,16 @@ class Projects extends Base {
.with({ project: 'project_id' });
}

async showProjectActivities(projectId, projectName) {
async loadProjectActivities(projectId) {
const events = await this.loadEvents(projectId);
events.forEach(event => {
delete event.author;
event.creation_day = new Date(event.created_at).setHours(0, 0, 0, 0);
});
db.events.bulkPut(events);
}

async showProjectActivities(projectId, projectName) {
let projectEvents = await this.getProjectEvents(projectId);
const updatedEvents = Charts.prepareProjectEvents(projectEvents);
const { data } = updatedEvents;
Expand Down

0 comments on commit fa2bea3

Please sign in to comment.