add ordinal in Language Entity
This commit is contained in:
parent
8bcc11d9a1
commit
cabb35cf19
|
@ -104,8 +104,8 @@ public class LanguageV2Controller {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("get-payload/{code}")
|
@GetMapping("code/{code}")
|
||||||
public ResponseEntity getPayload(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
|
public Language get(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
|
||||||
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("code", code).And("fields", fieldSet));
|
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("code", code).And("fields", fieldSet));
|
||||||
|
|
||||||
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
||||||
|
@ -124,9 +124,32 @@ public class LanguageV2Controller {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
|
|
||||||
return new ResponseEntity<>(model.getPayload().getBytes(), HttpStatus.OK);
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @GetMapping("get-payload/code/{code}")
|
||||||
|
// public ResponseEntity getPayload(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
|
||||||
|
// logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("code", code).And("fields", fieldSet));
|
||||||
|
//
|
||||||
|
// this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
||||||
|
//
|
||||||
|
// LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
|
||||||
|
// Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
||||||
|
//
|
||||||
|
// if (model == null)
|
||||||
|
// throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
//
|
||||||
|
// if (model.getPayload() == null){
|
||||||
|
// model.setPayload(this.languageService.getPayload(code));
|
||||||
|
// }
|
||||||
|
// this.auditService.track(AuditableAction.Language_Lookup, Map.ofEntries(
|
||||||
|
// new AbstractMap.SimpleEntry<String, Object>("code", code),
|
||||||
|
// new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
// ));
|
||||||
|
//
|
||||||
|
// return new ResponseEntity<>(model.getPayload().getBytes(), HttpStatus.OK);
|
||||||
|
// }
|
||||||
|
|
||||||
@PostMapping("available-languages")
|
@PostMapping("available-languages")
|
||||||
public QueryResult<String> queryLanguageCodes(@RequestBody LanguageLookup lookup) {
|
public QueryResult<String> queryLanguageCodes(@RequestBody LanguageLookup lookup) {
|
||||||
logger.debug("querying {}", Language.class.getSimpleName());
|
logger.debug("querying {}", Language.class.getSimpleName());
|
||||||
|
|
|
@ -36,11 +36,13 @@ export class LanguageHttpService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getPayload(code: string, reqFields: string[] = []): Observable<HttpResponse<Blob>> {
|
getSingleWithCode(code: string, reqFields: string[] = []): Observable<Language> {
|
||||||
const url = `${this.apiBase}/get-payload/${code}`;
|
const url = `${this.apiBase}/code/${code}`;
|
||||||
const options = { params: { f: reqFields }, responseType: 'blob', observe: 'response' };
|
const options = { params: { f: reqFields } };
|
||||||
|
|
||||||
return this.http.get(url, options);
|
return this.http
|
||||||
|
.get<Language>(url, options).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
queryAvailableCodes(q: LanguageLookup): Observable<QueryResult<string>> {
|
queryAvailableCodes(q: LanguageLookup): Observable<QueryResult<string>> {
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
// Rest dependencies. Inject any other needed deps here:
|
// Rest dependencies. Inject any other needed deps here:
|
||||||
public authService: AuthService,
|
public authService: AuthService,
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
private languageV2Service: LanguageHttpService,
|
private languageHttpService: LanguageHttpService,
|
||||||
private logger: LoggingService,
|
private logger: LoggingService,
|
||||||
private languageEditorService: LanguageEditorService,
|
private languageEditorService: LanguageEditorService,
|
||||||
private fileUtils: FileUtils,
|
private fileUtils: FileUtils,
|
||||||
|
@ -88,7 +88,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.matomoService.trackPageView('Admin: Languages');
|
this.matomoService.trackPageView('Admin: Languages');
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.languageV2Service.queryAvailableCodes(this.languageV2Service.buildAutocompleteLookup())
|
this.languageHttpService.queryAvailableCodes(this.languageHttpService.buildAutocompleteLookup())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => this.availableLanguageCodes = data.items,
|
data => this.availableLanguageCodes = data.items,
|
||||||
|
@ -96,7 +96,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem(itemId: Guid, successFunction: (item: Language) => void) {
|
getItem(itemId: Guid, successFunction: (item: Language) => void) {
|
||||||
this.languageV2Service.getSingle(itemId, LanguageEditorResolver.lookupFields())
|
this.languageHttpService.getSingle(itemId, LanguageEditorResolver.lookupFields())
|
||||||
.pipe(map(data => data as Language), takeUntil(this._destroyed))
|
.pipe(map(data => data as Language), takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => successFunction(data),
|
data => successFunction(data),
|
||||||
|
@ -107,17 +107,14 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
prepareForm(data: Language) {
|
prepareForm(data: Language) {
|
||||||
try {
|
try {
|
||||||
if(data && data.payload == null){
|
if(data && data.payload == null){
|
||||||
this.languageV2Service.getPayload(data.code, LanguageEditorResolver.lookupFields())
|
this.languageHttpService.getSingleWithCode(data.code, LanguageEditorResolver.lookupFields())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(respone => {
|
.subscribe(language => {
|
||||||
const blob = new Blob([respone.body], { type: 'text/html' });
|
data.payload = language.payload;
|
||||||
blob.text().then(text => {
|
|
||||||
data.payload = text;
|
|
||||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||||
this.buildForm();
|
this.buildForm();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||||
|
@ -156,7 +153,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
persistEntity(onSuccess?: (response) => void): void {
|
persistEntity(onSuccess?: (response) => void): void {
|
||||||
const formData = this.formService.getValue(this.formGroup.value) as LanguagePersist;
|
const formData = this.formService.getValue(this.formGroup.value) as LanguagePersist;
|
||||||
|
|
||||||
this.languageV2Service.persist(formData)
|
this.languageHttpService.persist(formData)
|
||||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
|
@ -185,7 +182,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.languageV2Service.delete(value.id).pipe(takeUntil(this._destroyed))
|
this.languageHttpService.delete(value.id).pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
|
@ -201,14 +198,10 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
||||||
}
|
}
|
||||||
|
|
||||||
public selectedCodeChanged(code: string){
|
public selectedCodeChanged(code: string){
|
||||||
this.languageV2Service.getPayload(code, LanguageEditorResolver.lookupFields())
|
this.languageHttpService.getSingleWithCode(code, LanguageEditorResolver.lookupFields())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(language => {
|
||||||
const blob = new Blob([response.body], { type: 'text/html' });
|
this.formGroup.get('payload').patchValue(language.payload);
|
||||||
blob.text().then(text => {
|
|
||||||
this.formGroup.get('payload').patchValue(text);
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue