Skip to content

Commit

Permalink
Merge branch 'master' into 6796-calendar-add-the-space-between-buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Nov 14, 2024
2 parents 15f1f2f + a1f970e commit dd450e2
Show file tree
Hide file tree
Showing 39 changed files with 588 additions and 81 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.15.17",
"version": "0.15.44",
"myplanet": {
"latest": "v0.20.69",
"min": "v0.19.69"
"latest": "v0.20.96",
"min": "v0.19.96"
},
"scripts": {
"ng": "ng",
Expand Down
13 changes: 11 additions & 2 deletions src/app/community/community-link-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CustomValidators } from '../validators/custom-validators';
import { TeamsService } from '../teams/teams.service';
import { switchMap } from 'rxjs/operators';
import { ValidatorService } from '../validators/validator.service';
import { PlanetMessageService } from '../shared/planet-message.service';

@Component({
templateUrl: './community-link-dialog.component.html',
Expand All @@ -25,6 +26,7 @@ export class CommunityLinkDialogComponent {
@Inject(MAT_DIALOG_DATA) public data: any,
private fb: FormBuilder,
private teamsService: TeamsService,
private planetMessageService: PlanetMessageService,
private validatorService: ValidatorService
) {
this.linkForm = this.fb.group({
Expand All @@ -50,10 +52,17 @@ export class CommunityLinkDialogComponent {
}

linkSubmit() {
const linkTitle = this.linkForm.get('title')?.value;
this.teamsService.createServicesLink(this.linkForm.value).pipe(
switchMap(() => this.data.getLinks())
).subscribe(() => {
this.dialogRef.close();
).subscribe({
next: () => {
this.dialogRef.close();
this.planetMessageService.showMessage(`${linkTitle} added successfully`);
},
error: () => {
this.planetMessageService.showAlert(`Error adding link`);
}
});
}

Expand Down
36 changes: 21 additions & 15 deletions src/app/community/community.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ <h3 style="text-align: right; margin-right: 0.5rem;">
<button mat-stroked-button (click)="openAddMessageDialog()" *ngIf="showNewsButton" i18n>New Voice</button>
</ng-container>
</h3>
<ng-container *ngIf="news?.length > 0; else noVoices">
<planet-news-list [items]="news" [shareTarget]="shareTarget" (viewChange)="toggleShowButton($event)" [viewableId]="teamId"></planet-news-list>
<ng-container *ngIf="isLoading; else loaded">
<span i18n>Loading voices...</span>
</ng-container>
<ng-template #loaded>
<ng-container *ngIf="news?.length > 0; else noVoices">
<planet-news-list [items]="news" [shareTarget]="shareTarget" (viewChange)="toggleShowButton($event)" [viewableId]="teamId"></planet-news-list>
</ng-container>
</ng-template>
<ng-template #noVoices>
<p i18n>No Voices available.</p>
</ng-template>
Expand All @@ -28,14 +33,24 @@ <h3 style="text-align: right; margin-right: 0.5rem;">
</div>
</mat-tab>
<mat-tab i18n-label label="Services">
<planet-markdown *ngIf="team.description" [content]="team.description || ''"></planet-markdown>
<p *ngIf="!team.description" i18n>No description available.</p>
<ng-container *ngIf="!planetCode">
<button *planetAuthorizedRoles="''" (click)="openDescriptionDialog()" mat-stroked-button i18n>
<button class="toggle-button" *planetAuthorizedRoles="''" (click)="openDescriptionDialog()" mat-stroked-button i18n>
{ servicesDescriptionLabel, select, Edit {Edit} Add {Add}} { configuration.planetType, select, community {Community} nation {Nation} center {Earth}} Description
</button>
</ng-container>
<ng-container *ngIf="links?.length > 0; else noLinks">
<planet-markdown *ngIf="team.description; else noTeamDesc" [content]="team.description || ''"></planet-markdown>
<ng-template #noTeamDesc><p i18n>No description available.</p></ng-template>
<ng-container *ngIf="!planetCode">
<div *planetAuthorizedRoles="''" class="action-buttons sticky-button">
<button (click)="openAddLinkDialog()" mat-stroked-button i18n>Add Link</button>
<button (click)="toggleDeleteMode()" [disabled]="links.length===0" mat-stroked-button>
<span *ngIf="!deleteMode" i18n>Remove Links</span>
<span *ngIf="deleteMode" i18n>Done Removing Links</span>
</button>
</div>
</ng-container>
<ng-container>
<span *ngIf="links?.length === 0" i18n><p>No links available.</p></span>
<mat-nav-list>
<mat-list-item *ngFor="let link of links" [routerLink]="(link.teamType === 'sync' || !planetCode) ? link.route : []" i18n-matTooltip [matTooltip]="(link.teamType === 'sync' || !planetCode) ? '' : link.title + ' is only available on ' + configuration.name" [disableRipple]="link.teamType === 'local' && planetCode">
<span matLine>{{link.title}}</span>
Expand All @@ -46,15 +61,6 @@ <h3 style="text-align: right; margin-right: 0.5rem;">
<ng-template #noLinks>
<p i18n>No links available.</p>
</ng-template>
<ng-container *ngIf="!planetCode">
<div *planetAuthorizedRoles="''" class="action-buttons">
<button (click)="openAddLinkDialog()" mat-stroked-button i18n>Add Link</button>
<button (click)="toggleDeleteMode()" [disabled]="links.length===0" mat-stroked-button>
<span *ngIf="!deleteMode" i18n>Remove Links</span>
<span *ngIf="deleteMode" i18n>Done Removing Links</span>
</button>
</div>
</ng-container>
</mat-tab>
<mat-tab *ngIf="configuration.planetType==='nation'" i18n-label label="Communities">
<planet-community-list></planet-community-list>
Expand Down
32 changes: 31 additions & 1 deletion src/app/community/community.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DialogsLoadingService } from '../shared/dialogs/dialogs-loading.service
import { MatDialog } from '@angular/material/dialog';
import { CommunityLinkDialogComponent } from './community-link-dialog.component';
import { TeamsService } from '../teams/teams.service';
import { DialogsAnnouncementComponent } from '../shared/dialogs/dialogs-announcement.component';
import { DialogsPromptComponent } from '../shared/dialogs/dialogs-prompt.component';
import { CouchService } from '../shared/couchdb.service';
import { PlanetMessageService } from '../shared/planet-message.service';
Expand Down Expand Up @@ -48,6 +49,8 @@ export class CommunityComponent implements OnInit, OnDestroy {
resizeCalendar: any = false;
deviceType: DeviceType;
deviceTypes = DeviceType;
challengeActive: boolean;
isLoading: boolean;

constructor(
private dialog: MatDialog,
Expand All @@ -68,9 +71,11 @@ export class CommunityComponent implements OnInit, OnDestroy {

ngOnInit() {
const newsSortValue = (item: any) => item.sharedDate || item.doc.time;
this.isLoading = true;
this.getCommunityData();
this.newsService.newsUpdated$.pipe(takeUntil(this.onDestroy$)).subscribe(news => {
this.news = news.sort((a, b) => newsSortValue(b) - newsSortValue(a));
this.isLoading = false;
});
this.usersService.usersListener(true).pipe(takeUntil(this.onDestroy$)).subscribe(users => {
if (!this.planetCode) {
Expand All @@ -83,6 +88,7 @@ export class CommunityComponent implements OnInit, OnDestroy {
this.setCouncillors(users);
}
});
this.communityChallenge();
}

@HostListener('window:resize') onResize() {
Expand All @@ -94,6 +100,25 @@ export class CommunityComponent implements OnInit, OnDestroy {
this.onDestroy$.complete();
}

communityChallenge() {
const includedCodes = [ 'guatemala', 'san.pablo', 'xela', 'embakasi', 'uriur' ];
this.challengeActive = includedCodes.includes(this.configuration.code) &&
((new Date() > new Date(2024, 9, 31)) && (new Date() < new Date(2024, 11, 1)));
const popupShown = localStorage.getItem('announcementPopupShown');

if (this.challengeActive && !popupShown) {
this.openAnnouncementDialog();
localStorage.setItem('announcementPopupShown', 'true');
}
}

openAnnouncementDialog() {
this.dialog.open(DialogsAnnouncementComponent, {
width: '50vw',
maxHeight: '100vh'
});
}

getCommunityData() {
const setShareTarget = (type) => type === 'center' ? 'nation' : type === 'nation' ? 'community' : undefined;
this.route.paramMap.pipe(
Expand Down Expand Up @@ -302,10 +327,15 @@ export class CommunityComponent implements OnInit, OnDestroy {
this.teamsService.updateTeam({ ...this.team, description: description.text }).pipe(
finalize(() => this.dialogsLoadingService.stop())
).subscribe(newTeam => {
const previousDescription = Boolean(this.team.description);
this.team = newTeam;
this.servicesDescriptionLabel = newTeam.description ? 'Edit' : 'Add';
const msg = newTeam.description
? (previousDescription ? $localize`Description edited` : $localize`Description added`)
: $localize`Description deleted`;
this.dialogsFormService.closeDialogsForm();
this.planetMessageService.showMessage(msg);
});
this.dialogsFormService.closeDialogsForm();
};
this.dialogsFormService.openDialogsForm(
this.team.description ? $localize`Edit Description` : $localize`Add Description`,
Expand Down
17 changes: 17 additions & 0 deletions src/app/community/community.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ planet-calendar {
right: -0.25rem;
}
}

mat-tab-group, mat-tab {
height: 100%;
}

.sticky-button {
position: sticky;
top: 0;
z-index: 10;
background-color: white;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
}

.toggle-button{
margin-bottom: 1rem;
}
1 change: 1 addition & 0 deletions src/app/courses/add-courses/courses-add.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-toolbar>
<a mat-icon-button (click)="navigateBack()"><mat-icon>arrow_back</mat-icon></a>
<span i18n>Add Course</span>
</mat-toolbar>

<div class="space-container">
Expand Down
1 change: 1 addition & 0 deletions src/app/courses/courses.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export class CoursesComponent implements OnInit, OnChanges, AfterViewInit, OnDes

removeFilteredFromSelection() {
this.selection.deselect(...selectedOutOfFilter(this.courses.filteredData, this.selection, this.paginator));
this.emptyData = this.courses.filteredData.length === 0;
}

onSearchChange({ items, category }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</mat-select>
</mat-form-field>
<button mat-raised-button color="accent" class="margin-lr-3" *ngIf="selectedStep !== undefined" (click)="resetToFullCourse()" i18n>Show full course</button>
<button class="margin-lr-10" color="accent" mat-raised-button i18n (click)="exportChartData()">
<button *ngIf="chartData?.length" class="margin-lr-10" color="accent" mat-raised-button i18n (click)="exportChartData()">
Export
</button>
</mat-toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="space-container">
<mat-toolbar class="primary-color font-size-1">
<h3 class="margin-lr-3 ellipsis-title"><ng-container i18n>Step</ng-container> {{stepNum}}<span *ngIf="stepDetail.stepTitle">: </span>{{stepDetail.stepTitle}}</h3>
<button *ngIf="isOpenai" mat-stroked-button class="margin-lr-3" (click)="showChat = !showChat" i18n>
<button *ngIf="isOpenai && stepDetail?.description" mat-stroked-button class="margin-lr-3" (click)="showChat = !showChat" i18n>
{{ showChat ? 'Hide Course Chat' : 'Show Course Chat' }}
</button>
<span class="toolbar-fill"></span>
Expand Down Expand Up @@ -70,15 +70,15 @@ <h3 class="margin-lr-3 ellipsis-title"><ng-container i18n>Step</ng-container> {{
</div>
</mat-toolbar>
<div class="view-container view-full-height" [ngClass]="{'grid-view': showChat, 'flex-view': !isGridView && !showChat}" *ngIf="stepDetail?.description || resource?._attachments; else emptyRecord">
<planet-chat-window *ngIf="showChat" [context]="{type: 'coursestep', data: localizedStepInfo, resource: { id: resource._id, attachments: resource._attachments } }"></planet-chat-window>
<planet-chat-window *ngIf="showChat" [context]="{type: 'coursestep', data: localizedStepInfo, resource: { id: resource?._id, attachments: resource?._attachments } }"></planet-chat-window>
<ng-container *ngIf="showChat; else stepViewContent">
<div class="flex-view">
<ng-container *ngTemplateOutlet="stepViewContent"></ng-container>
</div>
</ng-container>
<ng-template #stepViewContent>
<planet-markdown *ngIf="stepDetail?.description" class="description img-resize" [content]="stepDetail.description"></planet-markdown>
<div>
<div *ngIf="resource?._attachments">
<mat-button-toggle-group class="full-width-toggle-group" *ngIf="stepDetail.resources.length > 1" [(ngModel)]="resource" (change)="onResourceChange($event.value)">
<mat-button-toggle *ngFor="let resource of stepDetail.resources; index as i" [value]="resource" class="full-width-toggle" [matTooltip]="resource.title" i18n>{{resource.title}}</mat-button-toggle>
</mat-button-toggle-group>
Expand Down
3 changes: 2 additions & 1 deletion src/app/courses/view-courses/courses-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ <h3 class="margin-lr-3 ellipsis-title">{{courseDetail.courseTitle}}</h3>
</mat-action-row>
</mat-expansion-panel>
</ng-container>
<span *ngIf="courseDetail.steps.length===0" i18n>There is no content for this course</span>
<span *ngIf="isLoading" i18n>Loading course details...</span>
<span *ngIf="courseDetail.steps.length===0 && !isLoading" i18n>There is no content for this course</span>
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/app/courses/view-courses/courses-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class CoursesViewComponent implements OnInit, OnDestroy {
currentView: string;
courseId: string;
canManage: boolean;
isLoading: boolean;
currentUser = this.userService.get();
planetConfiguration = this.stateService.configuration;
examText: 'retake' | 'take' = 'take';
Expand All @@ -48,9 +49,11 @@ export class CoursesViewComponent implements OnInit, OnDestroy {
}

ngOnInit() {
this.isLoading = true;
this.coursesService.courseUpdated$.pipe(
switchMap(({ course, progress = [ { stepNum: 0 } ] }: { course: any, progress: any }) => {
this.courseDetail = course;
this.isLoading = false;
this.coursesService.courseActivity('visit', course);
this.courseDetail.steps = this.courseDetail.steps.map((step, index) => ({
...step,
Expand Down
3 changes: 3 additions & 0 deletions src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ <h1 class="mat-title">
</mat-icon>
</span>
</div>
<div class="cursor-pointer" (click)="openChallengeView()" matTooltip="challenge">
<mat-icon>stars</mat-icon>
</div>
</div>
</mat-card>
<planet-dashboard-tile
Expand Down
8 changes: 8 additions & 0 deletions src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CoursesService } from '../courses/courses.service';
import { CoursesViewDetailDialogComponent } from '../courses/view-courses/courses-view-detail.component';
import { foundations, foundationIcons } from '../courses/constants';
import { CertificationsService } from '../manager-dashboard/certifications/certifications.service';
import { DialogsAnnouncementComponent } from '../shared/dialogs/dialogs-announcement.component';

@Component({
templateUrl: './dashboard.component.html',
Expand Down Expand Up @@ -211,4 +212,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.badgeGroups = [ ...foundations, 'none' ].filter(group => this.badgesCourses[group] && this.badgesCourses[group].length);
}

openChallengeView() {
this.dialog.open(DialogsAnnouncementComponent, {
width: '50vw',
maxHeight: '100vh'
});
}

}
8 changes: 4 additions & 4 deletions src/app/health/health-event.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ export class HealthEventComponent implements OnInit {
isFieldValueExpected(field) {
const value = this.healthForm.controls[field].value;
const limits = {
'temperature': { min: 30, max: 40 },
'pulse': { min: 40, max: 120 },
'height': { min: 1, max: 250 },
'weight': { min: 1, max: 150 },
'temperature': { min: 30, max: 45 },
'pulse': { min: 30, max: 300 },
'height': { min: 30, max: 275 },
'weight': { min: 0, max: 500 },
'bp': 'n/a'
};
if (value === null || value === '' || !limits[field]) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/health/health.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h4 class="full-width" i18n>Examinations</h4>
<mat-table [dataSource]="eventTable" *ngIf="events.length > 0">
<ng-container *ngFor="let column of displayedColumns" [matColumnDef]="column" [sticky]="column === 'label'">
<mat-header-cell *matHeaderCellDef class="table-column" [ngClass]="{ 'cursor-pointer': column !== 'label' }" (click)="examClick(column)">
<div>
<div class="header-items">
<div class="header-date">
{{ column === 'label' ? '' : (column | date) }}<mat-icon *ngIf="additionalInfo[column]?.hasInfo===true || additionalInfo[column]?.hasConditions===true" class="primary-text-color" i18n-tooltip matTooltip="Click for more information" [inline]="true">info</mat-icon>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/app/health/health.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ $exam-table-col-width: 100px;
overflow-x: auto;
}

.header-items{
margin-left: 1.5rem;
}

.header-items{
margin-left: 1.6rem;
}

mat-table {
width: max-content;

Expand All @@ -46,7 +54,10 @@ mat-table {
margin-left: 0.25rem;
font-size: 1.4em;
}
}

mat-cell{
margin-left: 3rem;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
this.progress.enrollments.filter(this.filter);
this.progress.completions.filter(this.filter);
this.progress.steps.filter(this.filter);
this.setStepCompletion();
this.setUserCounts(this.activityService.groupUsers(
this.users.filter(
user => this.filter.members.length === 0 || this.filter.members.some(
Expand Down
1 change: 1 addition & 0 deletions src/app/resources/resources-add.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-toolbar *ngIf="!isDialog">
<a mat-icon-button routerLink="/resources"><mat-icon>arrow_back</mat-icon></a>
<span i18n>Add Resource</span>
</mat-toolbar>

<div [ngClass]="{'space-container':!isDialog}">
Expand Down
1 change: 1 addition & 0 deletions src/app/resources/resources.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class ResourcesComponent implements OnInit, AfterViewInit, OnDestroy {

removeFilteredFromSelection() {
this.selection.deselect(...selectedOutOfFilter(this.resources.filteredData, this.selection, this.paginator));
this.emptyData = this.resources.filteredData.length === 0;
}


Expand Down
Loading

0 comments on commit dd450e2

Please sign in to comment.