Skip to content

Commit

Permalink
added quest achievements module, added achievements link, fix mission…
Browse files Browse the repository at this point in the history
… icon, tested
  • Loading branch information
ivan-balias committed Nov 7, 2024
1 parent 85a926b commit 2057127
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ const routes: Routes = [
import('./modules/questmission/pages/missions/missions.module').then(
(m) => m.QuestmissionModule
)
},
{
path: 'achievements',
canActivate: [MetaGuard],
data: {
meta: {
title: 'Achievements'
}
},
loadChildren: () =>
import('./modules/questachievement/pages/achievements/achievements.module').then(
(m) => m.QuestachievementModule
)
}
]
},
Expand Down
12 changes: 11 additions & 1 deletion src/app/core/theme/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,19 @@
class="nav__burger-link"
(click)="hideSidebar()"
>
<span class="material-icons">target</span>
<span class="material-icons">flag</span>
<span translate>Theme.Missions</span>
</a>
<a
[routerLinkActiveOptions]="{ exact: true }"
routerLinkActive="_activeLink"
routerLink="/achievements"
class="nav__burger-link"
(click)="hideSidebar()"
>
<span class="material-icons">emoji_events</span>
<span translate>Theme.Achievements</span>
</a>
<hr />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export const questachievementFormComponents = {
formId: 'questachievement',
title: 'Questachievement',
components: [
{
name: 'Text',
key: 'name',
focused: true,
fields: [
{
name: 'Placeholder',
value: 'fill questachievement title',
},
{
name: 'Label',
value: 'Title',
}
]
},
{
name: 'Text',
key: 'description',
fields: [
{
name: 'Placeholder',
value: 'fill questachievement description',
},
{
name: 'Label',
value: 'Description',
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CrudDocument } from 'wacom';

export interface Questachievement extends CrudDocument {
name: string;
description: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wtable
title="Achievements"
[columns]="columns"
[config]="config"
[rows]="rows"
></wtable>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Component } from '@angular/core';
import { AlertService, CoreService } from 'wacom';
import { QuestachievementService } from '../../services/questachievement.service';
import { Questachievement } from '../../interfaces/questachievement.interface';
import { FormService } from 'src/app/core/modules/form/form.service';
import { TranslateService } from 'src/app/core/modules/translate/translate.service';
import { FormInterface } from 'src/app/core/modules/form/interfaces/form.interface';
import { questachievementFormComponents } from '../../formcomponents/questachievement.formcomponents';

@Component({
templateUrl: './achievements.component.html',
styleUrls: ['./achievements.component.scss']
})
export class AchievementsComponent {
columns = ['name', 'description'];

form: FormInterface = this._form.getForm('questachievement', questachievementFormComponents);

config = {
create: (): void => {
this._form.modal<Questachievement>(this.form, {
label: 'Create',
click: (created: unknown, close: () => void) => {
this._questachievementService.create(created as Questachievement);

close();
}
});
},
update: (doc: Questachievement): void => {
this._form.modal<Questachievement>(this.form, [], doc).then((updated: Questachievement) => {
this._core.copy(updated, doc);

this._questachievementService.update(doc);
});
},
delete: (doc: Questachievement): void => {
this._alert.question({
text: this._translate.translate(
'Common.Are you sure you want to delete this questachievement?'
),
buttons: [
{
text: this._translate.translate('Common.No')
},
{
text: this._translate.translate('Common.Yes'),
callback: (): void => {
this._questachievementService.delete(doc);
}
}
]
});
},
buttons: [
{
icon: 'cloud_download',
click: (doc: Questachievement): void => {
this._form.modalUnique<Questachievement>('questachievement', 'url', doc);
}
}
]
};

get rows(): Questachievement[] {
return this._questachievementService.questachievements;
}

constructor(
private _translate: TranslateService,
private _questachievementService: QuestachievementService,
private _alert: AlertService,
private _form: FormService,
private _core: CoreService
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { CoreModule } from 'src/app/core/core.module';
import { AchievementsComponent } from './achievements.component';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
component: AchievementsComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes), CoreModule],
declarations: [AchievementsComponent],
providers: []
})
export class QuestachievementModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wselect
(modelChange)="onChange.emit($event)"
placeholder="Select questachievement"
[select]="value"
[items]="items"
></wselect>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
SimpleChanges,
EventEmitter,
Component,
OnChanges,
Output,
Input
} from '@angular/core';
import { SelectModule } from 'src/app/core/modules/select/select.module';
import { QuestachievementService } from '../../services/questachievement.service';
import { Questachievement } from '../../interfaces/questachievement.interface';

@Component({
selector: 'questachievement-selector',
templateUrl: './questachievement-selector.component.html',
styleUrls: ['./questachievement-selector.component.scss'],
standalone: true,
imports: [SelectModule]
})
export class SelectUserComponent implements OnChanges {
@Input() value: string;

@Output() wChange = new EventEmitter();

get items(): Questachievement[] {
return this._questachievementService.questachievements;
}

constructor(private _questachievementService: QuestachievementService) {}

ngOnChanges(changes: SimpleChanges): void {
if (changes['value'] && !changes['value'].firstChange) {
this.value = changes['value'].currentValue;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { Questachievement } from '../interfaces/questachievement.interface';
import {
AlertService,
CoreService,
HttpService,
StoreService,
CrudService
} from 'wacom';

@Injectable({
providedIn: 'root',
})
export class QuestachievementService extends CrudService<Questachievement> {
questachievements: Questachievement[] = this.getDocs();

questachievementsByAuthor: Record<string, Questachievement[]> = {};

constructor(
_http: HttpService,
_store: StoreService,
_alert: AlertService,
_core: CoreService
) {
super(
{
name: 'questachievement',
},
_http,
_store,
_alert,
_core
);

this.get();

this.filteredDocuments(this.questachievementsByAuthor);
}
}

0 comments on commit 2057127

Please sign in to comment.