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 calender #185

Merged
merged 23 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
05e8b35
map out calender creation logic
khalifan-kfan Sep 29, 2023
8c9efb0
chore: design the create calender component
khalifan-kfan Sep 29, 2023
0ff8c0c
fix: change routing and correct spellings
khalifan-kfan Oct 2, 2023
f195e56
chore: give data a single center point
khalifan-kfan Oct 5, 2023
19c9b0e
list out calender items
khalifan-kfan Oct 5, 2023
737500a
add season table components
khalifan-kfan Oct 8, 2023
c5f512f
connect to real data
khalifan-kfan Oct 8, 2023
6e2ff78
remove null data type
khalifan-kfan Oct 8, 2023
27e75dd
import calendar data from the service
khalifan-kfan Oct 8, 2023
e61325f
add crop title editor dialog
khalifan-kfan Oct 8, 2023
69a8575
correct component structure and activities dialog
khalifan-kfan Oct 8, 2023
7f82c58
enable crop activities editing
khalifan-kfan Oct 9, 2023
9f9a695
chore: edit out unneeded content
khalifan-kfan Oct 9, 2023
238176e
chore: use rxdb
khalifan-kfan Oct 22, 2023
b25032b
Merge branch 'main' into feat-seasonal-calender
khalifan-kfan Oct 22, 2023
8cf66d9
fix: typo and add edit design
khalifan-kfan Oct 31, 2023
387e540
enable weather condition editing
khalifan-kfan Oct 31, 2023
aebcd82
chore: enable name editing and fix schema
khalifan-kfan Oct 31, 2023
09b61a0
chore: add crop adder and remover
khalifan-kfan Oct 31, 2023
b5c65b7
chore: enable month deleting
khalifan-kfan Oct 31, 2023
9a0e9ca
Merge branch 'main' into feat-seasonal-calender
chrismclarke Nov 8, 2023
5b45724
refactor: shared crop select
chrismclarke Nov 8, 2023
645b779
chore: code tidying
chrismclarke Nov 8, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ export const ROUTES_COMMON: Routes = [
loadChildren: () => import('./pages/home/home.module').then((m) => m.HomeModule),
title: 'Seasonal Calendar',
},
{
path: 'create-calendar',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(non-blocking)
The url will already have /seasonal-calendar/ so probably can just call the child routes /create and /[calendarId] to view

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, thanks for this @chrismclarke

loadChildren: () => import('./pages/create-calendar/create-calendar.module').then((m) => m.CreateCalendarModule),
title: 'Create Calendar',
},
{
path: 'calendar-table',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(non-blocking)
The urls might look a bit cleaner if instead of this path you used a route paramater, e.g. path: ':id' which will make the the id available on page load. E.g. picsa.app/seasonal-calendar/abcd123 will be able to load info for seasonal calendar with local id abcd123
https://angular.io/guide/router-reference#configuration

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Ill try to handle that issue aswell

loadChildren: () => import('./pages/calender-table/calendar-table.module').then((m) => m.CalenderTableModule),
title: 'Calendar Table',
},
];
/** Routes only registered in standalone mode */
const ROUTES_STANDALONE: Routes = [{ path: '**', redirectTo: '' }];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { SeasonalCalendarMaterialModule } from './components/material.module';


/** Core imports only required when running standalone */
const StandaloneImports = [
AppRoutingModule,
Expand Down
3 changes: 0 additions & 3 deletions apps/picsa-tools/seasonal-calendar-tool/src/app/app.routes.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="table-container">
<h2 class="dialog-title">Add Activity</h2>
<div class="dialog-body">
<mat-form-field>
<mat-label>Select Activity</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>
<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>
</div>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.table-container {
width: 23rem;
text-align: center;

.dialog-title {
margin-bottom: 1rem;
}

.dialog-body {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.4rem;
}
.inputField{
padding: .5rem;
font-size: 16px;
border-radius: 5px;
width: 12rem;
}
.selectField{
padding: .5rem;
}

.buttons {
display: flex;
justify-content: center;
margin-top: 1rem;

.add-button {
margin-right: 1rem;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivitiesEditorDialogComponent } from './activities-editor-dialog.component';

describe('ActivitiesEditorDialogComponent', () => {
let component: ActivitiesEditorDialogComponent;
let fixture: ComponentFixture<ActivitiesEditorDialogComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ActivitiesEditorDialogComponent],
}).compileComponents();

fixture = TestBed.createComponent(ActivitiesEditorDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA,MatDialogRef } from '@angular/material/dialog';

@Component({
selector: 'seasonal-calendar-editor-dialog',
templateUrl: './activities-editor-dialog.component.html',
styleUrls: ['./activities-editor-dialog.component.scss'],
})
export class ActivitiesEditorDialogComponent {
activities: string[] = ['Preparation', 'Weeding', 'Havesting', 'Drying', 'Other'];
selectedActivity = '';
customActivity = '';


constructor(
public dialogRef: MatDialogRef<ActivitiesEditorDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to see you were able to figure out passing data in/out of dialogs

) {}

onSave(): void {
let result: string | null = this.selectedActivity;
if (this.selectedActivity === 'Other') {
const trimmedCustomActivity = this.customActivity.trim();
if (trimmedCustomActivity !== '') {
result = trimmedCustomActivity;
} else {
result = null;
}
}
this.dialogRef.close(result);
}
onClose(): void {
this.dialogRef.close();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { RouterModule } from '@angular/router';
import { PicsaCommonComponentsModule } from '@picsa/components';
import { PicsaTranslateModule } from '@picsa/shared/modules';

import { ActivitiesEditorDialogComponent } from './activities-editor-dialog/activities-editor-dialog.component';
import { CropDialogComponent } from './crop-dialog-component/crop-dialog-component.component';
// Local components
import { SeasonalCalendarMaterialModule } from './material.module';
import { MonthDialogComponent } from './month-editor-dialog/crop-dialog-component.component';

const Components = [];
const Components = [CropDialogComponent,ActivitiesEditorDialogComponent,MonthDialogComponent];

@NgModule({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="dialog-container">
<h2 class="dialog-container" >{{ data.name }} Extra information</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>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.dialog-container{
width: 25rem;
.dialog-container{
font-weight: 700;
}
.inputField{
padding: .5rem;
width: 14rem;
font-size: 16px;
border-radius: 5px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CropDialogComponent } from './crop-dialog-component.component';

describe('CropDialogComponent', () => {
let component: CropDialogComponent;
let fixture: ComponentFixture<CropDialogComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CropDialogComponent],
}).compileComponents();

fixture = TestBed.createComponent(CropDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA,MatDialogRef } from '@angular/material/dialog';

import { Crop } from '../../schema/schema_v0';

@Component({
selector: 'seasonal-calendar-dialog-component',
templateUrl: './crop-dialog-component.component.html',
styleUrls: ['./crop-dialog-component.component.scss'],
})
export class CropDialogComponent {
editedExtraInformation: string;

constructor(
public dialogRef: MatDialogRef<CropDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: Crop
) {
this.editedExtraInformation = data.extraInformation;
}

onClose(): void {
this.dialogRef.close();
}

onSave(): void {
this.data.extraInformation = this.editedExtraInformation;
this.dialogRef.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MatStepperModule } from '@angular/material/stepper';
import { MatTableModule } from '@angular/material/table';
import { DomSanitizer } from '@angular/platform-browser';


const COMPONENTS = [MatButtonModule, MatDialogModule, MatIconModule, MatSelectModule, MatStepperModule, MatTableModule];
// use custom module to make it easier to control what is available through app
@NgModule({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="dialog-container">
<h2 class="dialog-container" >Edit {{ data.month }} weather condition</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>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.dialog-container{
width: 25rem;
.dialog-container{
font-weight: 700;
}
.inputField{
padding: .5rem;
width: 14rem;
font-size: 16px;
border-radius: 5px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MonthDialogComponent } from './crop-dialog-component.component';

describe('MonthDialogComponent', () => {
let component: MonthDialogComponent;
let fixture: ComponentFixture<MonthDialogComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MonthDialogComponent],
}).compileComponents();

fixture = TestBed.createComponent(MonthDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA,MatDialogRef } from '@angular/material/dialog';

import { MonthData } from '../../schema/schema_v0';

@Component({
selector: 'seasonal-calendar-month-editor',
templateUrl: './crop-dialog-component.component.html',
styleUrls: ['./crop-dialog-component.component.scss'],
})
export class MonthDialogComponent {
weather: string;

constructor(
public dialogRef: MatDialogRef<MonthDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: MonthData
) {
this.weather = data.weather;
}

onClose(): void {
this.dialogRef.close();
}

onSave(): void {
this.data.weather = this.weather;
this.dialogRef.close();
}
}
Loading
Loading