Skip to content

Commit

Permalink
feat: new acore_string editor (#3210)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Borzì <[email protected]>
  • Loading branch information
Exitare and FrancescoBorzi authored Dec 21, 2024
1 parent fb5d4fe commit eeb0d78
Show file tree
Hide file tree
Showing 33 changed files with 710 additions and 16 deletions.
12 changes: 12 additions & 0 deletions apps/keira/src/app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ import {
SelectBroadcastTextComponent,
SelectNpcTextComponent,
SelectPageTextComponent,
AcoreStringComponent,
AcoreStringHandlerService,
SelectAcoreStringComponent,
} from 'texts';

export const KEIRA_ROUTES: Routes = [
Expand Down Expand Up @@ -406,6 +409,15 @@ export const KEIRA_ROUTES: Routes = [
component: NpcTextComponent,
canActivate: [NpcTextHandlerService],
},
{
path: 'acore-string',
component: AcoreStringComponent,
canActivate: [AcoreStringHandlerService],
},
{
path: 'select-acore-string',
component: SelectAcoreStringComponent,
},
],
},
{
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
"SELECT_NPC_TEXT": "NPC-Text auswählen",
"NPC_TEXT": "NPC-Text",
"SELECT_PAGE_TEXT": "Seiten-Text auswählen",
"PAGE_TEXT": "Seiten-Text"
"PAGE_TEXT": "Seiten-Text",
"ACORE_STRING_TEXT": "Acore-String Texts",
"SELECT_ACORE_STRING_TEXT": "Acore-String Texts auswählen"
},
"GOSSIP": {
"TITLE": "Klatsch",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
"ID": "The ID of the text in the page. This number is unique to every text ID.",
"NEXT_PAGE_ID": "The ID of the next page's text ID.",
"TEXT": "The actual text. The message in this field will be shown as the text on a page."
}
},
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Ventana de Texto de Criatura",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Разговоры",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "Gossip",
Expand Down
4 changes: 3 additions & 1 deletion apps/keira/src/assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
"SELECT_NPC_TEXT": "Select NPC Text",
"NPC_TEXT": "NPC Text",
"SELECT_PAGE_TEXT": "Select Page Text",
"PAGE_TEXT": "Page Text"
"PAGE_TEXT": "Page Text",
"ACORE_STRING_TEXT": "Acore Strings",
"SELECT_ACORE_STRING_TEXT": "Select Acore Strings"
},
"GOSSIP": {
"TITLE": "闲聊对话",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TestBed } from '@angular/core/testing';
import { AcoreStringHandlerService } from './acore-string-handler.service';
import { ACORE_STRING_TABLE } from '@keira/shared/acore-world-model';

describe(AcoreStringHandlerService.name, () => {
beforeEach(() =>
TestBed.configureTestingModule({
providers: [AcoreStringHandlerService],
}),
);

const setup = () => {
const service = TestBed.inject(AcoreStringHandlerService);
return { service };
};

it('isUnsaved should return the value of the statusMap for the broadcast_text table', () => {
const { service } = setup();
expect(service.isUnsaved).toBe(false); // defaults to false

service.statusMap[ACORE_STRING_TABLE] = true;
expect(service.isUnsaved).toBe(true);

service.statusMap[ACORE_STRING_TABLE] = false;
expect(service.isUnsaved).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Injectable } from '@angular/core';
import { HandlerService } from '@keira/shared/base-abstract-classes';
import { ACORE_STRING_TABLE, AcoreString } from '@keira/shared/acore-world-model';

@Injectable({
providedIn: 'root',
})
export class AcoreStringHandlerService extends HandlerService<AcoreString> {
protected readonly mainEditorRoutePath = 'texts/acore-string';

get isUnsaved(): boolean {
return this.statusMap[ACORE_STRING_TABLE];
}

protected _statusMap = {
[ACORE_STRING_TABLE]: false,
};
}
73 changes: 73 additions & 0 deletions libs/features/texts/src/acore-string/acore-string.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<keira-top-bar [selected]="handlerService.selected" [selectedName]="handlerService.selectedName" [isNew]="handlerService.isNew" />

<div class="container-fluid">
@if (editorService.loading) {
<span [translate]="'LOADING'"></span>
}

@if (editorService.form && !!editorService.loadedEntityId && !editorService.loading) {
<div>
<div class="content-block">
<keira-query-output [docUrl]="docUrl" [editorService]="editorService" (executeQuery)="save($event)" />
</div>
<form [formGroup]="editorService.form" class="form-group edit-form">
<div class="content-block">
<div class="row">
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<label class="control-label" for="entry">Entry</label>
<i class="fas fa-info-circle ms-1" placement="auto" [tooltip]="'OTHER_TEXTS.BROADCAST_TEXT.ID' | translate"></i>
<input [formControlName]="'entry'" id="entry" type="text" class="form-control form-control-sm" />
</div>
</div>
<div class="row">
<div class="form-group col-12">
<label class="control-label" for="content_default">Content Default</label>
<textarea [formControlName]="'content_default'" id="content_default" class="form-control form-control-sm" rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_koKR">Locale koKR</label>
<textarea [formControlName]="'locale_koKR'" id="locale_koKR" class="form-control form-control-sm" rows="5"></textarea>
</div>
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_frFR">Locale frFr</label>
<textarea [formControlName]="'locale_frFR'" id="locale_frFR" class="form-control form-control-sm" rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_deDE">Locale deDe</label>
<textarea [formControlName]="'locale_deDE'" id="locale_deDE" class="form-control form-control-sm" rows="5"></textarea>
</div>
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_zhCN">Locale zhCN</label>
<textarea [formControlName]="'locale_zhCN'" id="locale_zhCN" class="form-control form-control-sm" rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_zhTW">Locale zhTW</label>
<textarea [formControlName]="'locale_zhTW'" id="locale_zhTW" class="form-control form-control-sm" rows="5"></textarea>
</div>
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_esES">Locale esES</label>
<textarea [formControlName]="'locale_esES'" id="locale_esES" class="form-control form-control-sm" rows="5"></textarea>
</div>
</div>

<div class="row">
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_esMX">Locale esMX</label>
<textarea [formControlName]="'locale_esMX'" id="locale_esMX" class="form-control form-control-sm" rows="5"></textarea>
</div>
<div class="form-group col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label class="control-label" for="locale_ruRU">Locale ruRU</label>
<textarea [formControlName]="'locale_ruRU'" id="locale_ruRU" class="form-control form-control-sm" rows="5"></textarea>
</div>
</div>
</div>
</form>
</div>
}
</div>
20 changes: 20 additions & 0 deletions libs/features/texts/src/acore-string/acore-string.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { AcoreString } from '@keira/shared/acore-world-model';
import { SingleRowEditorComponent } from '@keira/shared/base-abstract-classes';
import { TranslateModule } from '@ngx-translate/core';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { AcoreStringHandlerService } from './acore-string-handler.service';
import { AcoreStringService } from './acore-string.service';
import { QueryOutputComponent, TopBarComponent } from '@keira/shared/base-editor-components';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './acore-string.component.html',
standalone: true,
imports: [TranslateModule, ReactiveFormsModule, TooltipModule, QueryOutputComponent, TopBarComponent],
})
export class AcoreStringComponent extends SingleRowEditorComponent<AcoreString> {
override readonly editorService = inject(AcoreStringService);
protected override readonly handlerService = inject(AcoreStringHandlerService);
}
Loading

0 comments on commit eeb0d78

Please sign in to comment.