Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(seasonal-calendar): add translations #203

Merged
merged 8 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion apps/picsa-tools/seasonal-calendar-tool/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
"tsConfig": "apps/picsa-tools/seasonal-calendar-tool/tsconfig.app.json",
"assets": [
"apps/picsa-tools/seasonal-calendar-tool/src/favicon.ico",
"apps/picsa-tools/seasonal-calendar-tool/src/assets"
"apps/picsa-tools/seasonal-calendar-tool/src/assets",
{
"glob": "*.json",
"input": "libs/i18n/assets",
"output": "assets/i18n"
}
],
"styles": ["apps/picsa-tools/seasonal-calendar-tool/src/styles.scss", "libs/theme/src/_index.scss"],
"scripts": []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div class="table-container">
<h2 class="dialog-title">Add Activity</h2>
<h2 class="dialog-title">{{'Add Activity' | translate}}</h2>
<div class="dialog-body">
<mat-form-field>
<mat-label>Select Activity</mat-label>
<mat-label>{{'Select Activity' | translate}}</mat-label>
<mat-select class="selectField" [(ngModel)]="selectedActivity">
<mat-option *ngFor="let activity of activities" [value]="activity">
{{ activity }}
</mat-option>
</mat-select>
</mat-form-field>
<div *ngIf="selectedActivity === 'Other'">
<h4>Type other activity</h4>
<h4>{{'Type other activity' | translate}}</h4>
<input matInput class="inputField" placeholder="Custom Activity" [(ngModel)]="customActivity">
</div>
</div>
<div class="buttons">
<button mat-button class="add-button" (click)="onSave()" [mat-dialog-close]="selectedActivity || customActivity" [disabled]="!(selectedActivity || customActivity)">Add</button>
<button mat-button class="cancel-button" (click)="onClose()">Cancel</button>
<button mat-button class="add-button" (click)="onSave()" [mat-dialog-close]="selectedActivity || customActivity" [disabled]="!(selectedActivity || customActivity)">{{'Add' | translate}}</button>
<button mat-button class="cancel-button" (click)="onClose()">{{'Cancel' | translate}}</button>
</div>
</div>

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="dialog-container">
<h2 class="dialog-container" >{{ data.name }} Extra information</h2>
<h2 class="dialog-container" >{{ data.name }} {{'Extra information' | translate}}</h2>
<p>{{"Please include any information required about farming this crop."}}</p>
<input class="inputField" [(ngModel)]="editedExtraInformation" placeholder="Edit extra information" />
<div mat-dialog-actions>
<button mat-button (click)="onSave()">Save</button>
<button mat-button (click)="onClose()">Close</button>
<button mat-button (click)="onSave()">{{'Save'|translate}}</button>
<button mat-button (click)="onClose()">{{'Close'|translate}}</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div *ngIf="displayError" >
<span class="form-control-feedback fix-error-icon"></span>
<div class="error-msg">
{{ errorMsg }}
{{ errorMsg | translate }}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="dialog-container">
<h2 class="dialog-container" >Edit {{ data.month }} weather condition</h2>
<h2 class="dialog-container" >{{ 'Edit' | translate }} {{ data.month }} {{'weather condition' | translate}}</h2>
<p>{{"Enter the weather condition for this month"}}</p>
<input class="inputField" [(ngModel)]="weather" placeholder="Edit extra information" />
<div mat-dialog-actions>
<button mat-button (click)="onSave()">Save</button>
<button mat-button (click)="onClose()">Close</button>
<button mat-button (click)="onSave()">{{'Save' | translate}}</button>
<button mat-button (click)="onClose()">{{'Close' | translate}}</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<div *ngIf="calendarData" class="table-container">
<div class="header-section">
<h1>{{calendarData?.name}}</h1> <button class="" mat-button mat-raised-button (click)="saveCalendar()"
color="primary">Save</button>
<h1>{{ calendarData.name }}</h1>
<button class="" mat-button mat-raised-button (click)="saveCalendar()" color="primary">
{{ 'Save' | translate }}
</button>
</div>
<table class="calendar-table">
<thead>
Expand All @@ -10,29 +12,31 @@ <h1>{{calendarData?.name}}</h1> <button class="" mat-button mat-raised-button (c
<th *ngFor="let month of calendarData.timeAndConditions">
<div class="y-axis-header">
<div (click)="openMonthHeading(month)">
{{ month.month }} <br />
( {{ month.weather }})
{{ month.month | translate }} <br />
( {{ month.weather | translate }})
</div>
<mat-icon (click)="deleteMonth(month.month)" class="custom-trash-icon">delete</mat-icon>
</div>
</th>

</tr>
</thead>
<tbody>
<ng-container *ngFor="let crop of calendarData.crops">
<tr>
<td>
<div class="y-axis-header">
<span> {{ crop.name }} </span>
<span> {{ crop.name | translate }} </span>
<div class="y-axis-actions">
<mat-icon (click)="deleteCropData(crop)" class="custom-trash-icon">delete</mat-icon>
<mat-icon (click)="openCropDialog(crop)">info</mat-icon>
</div>
</div>
</td>
<td class="activities-cell" (click)="openAddActivityDialog(crop, month)"
*ngFor="let month of calendarData.timeAndConditions">
<td
class="activities-cell"
(click)="openAddActivityDialog(crop, month)"
*ngFor="let month of calendarData.timeAndConditions"
>
<div class="user-activity-list">
<div class="activity" *ngFor="let activity of getActivitiesForMonthAndCrop(month.month, crop).split(',')">
<ng-container *ngIf="activity.trim() !== ''">
Expand All @@ -48,7 +52,10 @@ <h1>{{calendarData?.name}}</h1> <button class="" mat-button mat-raised-button (c
</table>
<div class="crop-adder">
<button mat-button mat-raised-button color="primary" (click)="toggleCropAdder()">
{{ showCropAdder ? 'Hide Crop Adder' : 'Show Crop Adder' }}
@if (showCropAdder) {<span>{{ 'Hide Crops' | translate }}</span>
} @else{
<span>{{ 'Add Crop' | translate }}</span
>}
</button>
<div *ngIf="showCropAdder" class="select-box">
<!-- <div class="select-input-field">
Expand All @@ -72,9 +79,9 @@ <h1>{{calendarData?.name}}</h1> <button class="" mat-button mat-raised-button (c
<div class="select-input-field">
<picsa-form-crop-select [(ngModel)]="userCropNames"></picsa-form-crop-select>
</div>
<button mat-button mat-raised-button color="primary" (click)="addNewCrop()">
{{ 'Update Crops' | translate }}
</button>
<button mat-button mat-raised-button color="primary" (click)="addNewCrop()">
{{ 'Update Crops' | translate }}
</button>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import { SeasonCalenderService } from './../../services/calender.data.service';
export class CalendarTableComponent implements OnInit {
calendarData: any;
months: string[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September'];
crops: string[] = ['Maize', 'Beans', 'Peas'];
selectedCrop = '';
customCrop = '';
showCropAdder = false;
userCropNames: string[] = [];


constructor(
private route: ActivatedRoute,
private dialog: MatDialog,
Expand All @@ -33,10 +31,9 @@ export class CalendarTableComponent implements OnInit {
) {}

async ngOnInit() {

await this.service.ready();
this.route.params.subscribe((params) => {
const {id} = params;
const { id } = params;
if (id) {
this.fetchData(id)
.then((resData) => {
Expand Down Expand Up @@ -137,32 +134,32 @@ export class CalendarTableComponent implements OnInit {
if (cropIndex !== -1) {
this.calendarData.crops.splice(cropIndex, 1);
//update db
this.autoDbUpdate()
this.autoDbUpdate();
}
}
});
}
autoDbUpdate(){
//upadate db
this.service.addORUpdateData(this.calendarData, 'update');
//refreash crop names
this.userCropNames = this.calendarData.crops.map((crop: any) => crop.name);
autoDbUpdate() {
//upadate db
this.service.addORUpdateData(this.calendarData, 'update');
//refreash crop names
this.userCropNames = this.calendarData.crops.map((crop: any) => crop.name);
}

addNewCrop() {
for(let i =0; i<this.userCropNames.length; i++ )
//skip crops that already exist
if (!this.isCropNameDuplicate(this.userCropNames[i])) {
const newCrop: Crop = {
name: this.userCropNames[i],
months: this.calendarData.timeAndConditions.map((monthData) => ({
month: monthData.month,
activities: [],
})),
extraInformation: '',
};
this.calendarData.crops.push(newCrop);
}
for (let i = 0; i < this.userCropNames.length; i++)
//skip crops that already exist
if (!this.isCropNameDuplicate(this.userCropNames[i])) {
const newCrop: Crop = {
name: this.userCropNames[i],
months: this.calendarData.timeAndConditions.map((monthData) => ({
month: monthData.month,
activities: [],
})),
extraInformation: '',
};
this.calendarData.crops.push(newCrop);
}
this.autoDbUpdate();
this.showCropAdder = false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,81 @@
<div class="container">
<h2>Crops Seasonal calender</h2>
<h2>{{ 'Crops Seasonal calender' | translate }}</h2>
<div class="box">
<h2>Calender name</h2>
<input class="inputField" [(ngModel)]="calenderTitle" placeholder="Season of 85" />
<seasonal-calendar-error-display [displayError]="showMessageFlag && calenderTitle===''" errorMsg="Please add the calender title">
<h2>{{ 'Calender name' | translate }}</h2>
<input class="inputField" [(ngModel)]="calenderTitle" [placeholder]="'Season of 85' | translate" />
<seasonal-calendar-error-display
[displayError]="showMessageFlag && calenderTitle === ''"
errorMsg="Please add the calender title"
>
</seasonal-calendar-error-display>
</div>

<!-- Crops -->
<div class="box">
<h2>Season Crops</h2>
<h2>{{ 'Season Crops' | translate }}</h2>
<div class="select-box">
<div class="select-input-field">
<picsa-form-crop-select [(ngModel)]="userCrops"></picsa-form-crop-select>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && userCrops.length<1" errorMsg="Please select a crop">
<seasonal-calendar-error-display
[displayError]="showMessageFlag && userCrops.length < 1"
errorMsg="Please select a crop"
>
</seasonal-calendar-error-display>
</div>
</div>

<!-- Calendar Time -->
<div>
<h2>Calendar Time</h2>
<h2>{{ 'Calendar Time' | translate }}</h2>
<div class="calender-box">
<div>
<div class="form-group">
<label for="startMonth">Start Month:</label>
<select id="startMonth" [(ngModel)]="startMonth">
<option value="" disabled selected>Select start month</option>
<option *ngFor="let month of months" [value]="month">{{ month }}</option>
</select>
<div class="form-group">
<label for="startMonth">{{ 'Start Month ' | translate }} :</label>
<select id="startMonth" [(ngModel)]="startMonth">
<option value="" disabled selected>{{ 'Select start month' | translate }}</option>
<option *ngFor="let month of months" [value]="month">{{ month | translate }}</option>
</select>
</div>
<seasonal-calendar-error-display
[displayError]="showMessageFlag && startMonth === ''"
[errorMsg]="'Please select a start month' | translate"
>
</seasonal-calendar-error-display>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && startMonth ===''" errorMsg="Please select a start month">
</seasonal-calendar-error-display>
</div>
<div>
<div class="form-group">
<label for="numberOfMonths">Number of Months Needed:</label>
<input type="number" class="inputField" id="numberOfMonths" [(ngModel)]="numMonths" />
<div>
<div class="form-group">
<label for="numberOfMonths">{{ 'Number of Months Needed' | translate }}:</label>
<input type="number" class="inputField" id="numberOfMonths" [(ngModel)]="numMonths" />
</div>
<seasonal-calendar-error-display
[displayError]="showMessageFlag && numMonths < 1"
[errorMsg]="'Please enter the required number of months' | translate"
>
</seasonal-calendar-error-display>
</div>
<seasonal-calendar-error-display [displayError]="showMessageFlag && numMonths <1 " errorMsg="Please enter the required number of months">
</seasonal-calendar-error-display>
</div>
</div>
<h4 *ngIf="calendarMonths.length > 0">{{ "Enter the selected month's weather condition" | translate }}</h4>
<div class="monthsGrid">
<div *ngFor="let monthData of calendarMonths" class="month">
<div>{{ monthData.month }}</div>
<div>{{ monthData.month | translate }}</div>
<div>
<input placeholder="wet,dry..." type="text" class="inputField" [(ngModel)]="monthData.weather" />
<input
[placeholder]="'wet,dry...' | translate"
type="text"
class="inputField"
[(ngModel)]="monthData.weather"
/>
</div>
</div>
</div>
</div>
<div class="submit-button">
<button class="" mat-button mat-raised-button (click)="onSubmition()" color="primary">Create calender</button>
<button class="" mat-button mat-raised-button (click)="onSubmition()" color="primary">
{{ 'Create calender ' | translate }}
</button>
</div>
<div class="flag-message" *ngIf="showMessageFlag">
<p>{{ message }}</p>
<p>{{ message | translate }}</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';

// import { PicsaTranslateService } from '@picsa/shared/modules';
import { SeasonCalenderService } from './../../services/calender.data.service';

@Component({
Expand Down
Loading
Loading