-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable editing for a single translation
- Loading branch information
1 parent
189f2ec
commit de4690e
Showing
5 changed files
with
123 additions
and
21 deletions.
There are no files selected for viewing
41 changes: 39 additions & 2 deletions
41
...a-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
<div class="page-content"> | ||
<h2>Edit Translations</h2> | ||
@if(translationRow){ | ||
<form class="form-content"> | ||
<div> | ||
<label>Created At</label> | ||
<div>{{ translationRow.created_at | date: 'mediumDate' }}</div> | ||
</div> | ||
|
||
|
||
</div> | ||
<div class="form-data"> | ||
<label>English</label> | ||
<input matInput [(ngModel)]="translationRow.en" name="en" /> | ||
</div> | ||
|
||
<div class="form-data"> | ||
<label>mw_ny</label> | ||
<input matInput [(ngModel)]="translationRow.mw_ny" name="mw_ny" /> | ||
</div> | ||
|
||
<div class="form-data"> | ||
<label>sw</label> | ||
<input matInput [(ngModel)]="translationRow.sw" name="sw" /> | ||
</div> | ||
<div class="form-data"> | ||
<label>tg</label> | ||
<input matInput [(ngModel)]="translationRow.tg" name="tg" /> | ||
</div> | ||
<div class="form-data"> | ||
<label>zm_ny</label> | ||
<input matInput [(ngModel)]="translationRow.zm_ny" name="zm_ny" /> | ||
</div> | ||
<button mat-raised-button color="primary" class="submitButton" (click)="submitForm()">Submit</button> | ||
</form> | ||
} @else if(dataLoadError) { | ||
<div>{{dataLoadError}}</div> | ||
} @else { | ||
<div>Loading...</div> | ||
} | ||
@if(editActionFeedbackMessage){ | ||
<div>{{editActionFeedbackMessage}}</div> | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.form-content{ | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.4rem; | ||
} | ||
.submitButton{ | ||
width: 7rem; | ||
margin-bottom: 1rem; | ||
} | ||
.form-data{ | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
|
||
} | ||
input { | ||
padding: 8px; | ||
color: var(--color-primary); | ||
outline-color: var(--color-primary); | ||
max-width: 300px; | ||
display: block; | ||
font-size: 0.9rem; | ||
white-space: pre-wrap; | ||
word-wrap: break-word; | ||
|
||
} |
52 changes: 37 additions & 15 deletions
52
...csa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,55 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; | ||
import { FormBuilder, FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
// eslint-disable-next-line @nx/enforce-module-boundaries | ||
import type { Database } from '@picsa/server-types'; | ||
import { PICSAFormValidators } from '@picsa/shared/modules/forms/validators'; | ||
import type { Database } from '@picsa/server-types'; | ||
import { PICSAFormValidators } from '@picsa/shared/modules/forms/validators'; | ||
|
||
import { DashboardMaterialModule } from '../../../../material.module'; | ||
import { DashboardMaterialModule } from '../../../../material.module'; | ||
// import { DashboardResourcesStorageLinkComponent } from '../../components/storage-link/storage-link.component'; | ||
import { TranslationDashboardService } from '../../translations.service'; | ||
|
||
// type IResourceEntry = Database['public']['Tables']['resources']['Row']; | ||
type ITranslationEntry = Database['public']['Tables']['translations']['Row']; | ||
|
||
@Component({ | ||
selector: 'dashboard-translations-edit', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
DashboardMaterialModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
], | ||
imports: [CommonModule, DashboardMaterialModule, FormsModule, ReactiveFormsModule], | ||
templateUrl: './translations-edit.component.html', | ||
styleUrls: ['./translations-edit.component.scss'], | ||
}) | ||
export class TranslationsEditComponent { | ||
constructor( | ||
private service: TranslationDashboardService, | ||
private route: ActivatedRoute | ||
) {} | ||
translationRow: ITranslationEntry; | ||
dataLoadError: string; | ||
editActionFeedbackMessage: string; | ||
constructor(private service: TranslationDashboardService, private route: ActivatedRoute) { | ||
this.service.ready(); | ||
this.route.params.subscribe((params) => { | ||
const id = params['id']; | ||
this.service | ||
.getTranslationById(id) | ||
.then((data) => { | ||
this.translationRow = data; | ||
}) | ||
.catch((error) => { | ||
console.error('Error fetching translation:', error); | ||
this.dataLoadError = 'Failed to fetch translation.'; | ||
}); | ||
}); | ||
} | ||
|
||
submitForm() { | ||
this.service | ||
.updateTranslationById(this.translationRow.id, this.translationRow) | ||
.then((data) => { | ||
if (data === 'Updated successfully') { | ||
this.editActionFeedbackMessage = 'Updated successfully'; | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error('Error editing translation:', error); | ||
this.editActionFeedbackMessage = 'Failed to edit translation.'; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters