Skip to content

Commit

Permalink
Merge branch 'release/2.8.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Dec 8, 2023
2 parents 88fabec + f8c9599 commit f87908f
Show file tree
Hide file tree
Showing 47 changed files with 1,075 additions and 1,003 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "net.sumaris.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 20811
versionName "2.8.11"
versionCode 20812
versionName "2.8.12"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest android:versionCode="20811" android:versionName="2.8.11" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<manifest android:versionCode="20812" android:versionName="2.8.12" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="net.sumaris.app.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
<intent-filter>
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [[ "_$INSTALL_DIR" == "_" ]]; then
fi

latest_version() {
echo "2.8.11" #lastest
echo "2.8.12" #lastest
}

api_release_url() {
Expand Down
2 changes: 1 addition & 1 deletion ngx-sumaris-components
Submodule ngx-sumaris-components updated from 5bd7fc to 5e551e
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sumaris-app",
"description": "SUMARiS app",
"version": "2.8.11",
"version": "2.8.12",
"author": "[email protected]",
"license": "AGPL-3.0",
"readmeFilename": "README.md",
Expand Down Expand Up @@ -82,7 +82,7 @@
"@rx-angular/state": "^14.0.0",
"@rx-angular/template": "^14.0.0",
"@sgratzl/chartjs-chart-boxplot": "~3.9.1",
"@sumaris-net/ngx-components": "2.4.154",
"@sumaris-net/ngx-components": "2.4.155",
"angular-split": "^14.1.0",
"angular2-text-mask": "~9.0.0",
"apollo-angular": "~4.2.1",
Expand Down
8 changes: 4 additions & 4 deletions src/app/data/data.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TypePolicies } from '@apollo/client/core';
import {FormFieldDefinition, PRIORITIZED_AUTHORITIES, StatusIds} from '@sumaris-net/ngx-components';
import { FormFieldDefinition, PRIORITIZED_AUTHORITIES, StatusIds } from '@sumaris-net/ngx-components';
import { ReferentialRefFilter } from '@app/referential/services/filter/referential-ref.filter';
import DurationConstructor = moment.unitOfTime.DurationConstructor;
import {ReferentialRefFilter} from '@app/referential/services/filter/referential-ref.filter';

export const DATA_GRAPHQL_TYPE_POLICIES = <TypePolicies>{
DataReferenceVO: {
keyFields: ['entityName', 'id']
}
keyFields: ['entityName', 'id'],
},
};

export const DATA_IMPORT_PERIODS: readonly { value: number; unit: DurationConstructor }[] = Object.freeze([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface BaseEditorState {

@Directive()
// tslint:disable-next-line:directive-class-suffix
export abstract class AppBaseDataEntityEditor<
export abstract class AppDataEntityEditor<
T extends DataEntity<T, ID>,
S extends IEntityService<T, ID, any> = BaseEntityService<T, any, any>,
ID = number,
Expand All @@ -66,14 +66,12 @@ export abstract class AppBaseDataEntityEditor<
protected remoteStrategySubscription: Subscription;
protected canSendMessage = false;


readonly acquisitionLevel$ = this._state.select('acquisitionLevel');
readonly programLabel$ = this._state.select( 'programLabel');
readonly programLabel$ = this._state.select('programLabel');
readonly program$ = this._state.select('program');
readonly strategyLabel$ = this._state.select( 'strategyLabel');
readonly strategyLabel$ = this._state.select('strategyLabel');
readonly strategy$ = this._state.select('strategy');


get acquisitionLevel(): string {
return this._state.get('acquisitionLevel');
}
Expand Down Expand Up @@ -110,8 +108,8 @@ export abstract class AppBaseDataEntityEditor<

protected constructor(injector: Injector, dataType: new () => T, dataService: S, options?: AppEditorOptions) {
super(injector, dataType, dataService, {
autoOpenNextTab: !(injector.get(LocalSettingsService).mobile),
...options
autoOpenNextTab: !injector.get(LocalSettingsService).mobile,
...options,
});

this.programRefService = injector.get(ProgramRefService);
Expand All @@ -129,49 +127,57 @@ export abstract class AppBaseDataEntityEditor<
super.ngOnInit();

// Watch program, to configure tables from program properties
this._state.connect('program',
this._state.connect(
'program',
merge(
this.programLabel$.pipe(distinctUntilChanged()),
// Allow to force reload (e.g. when program remotely changes - see startListenProgramRemoteChanges() )
this._onReloadProgram.pipe(map(() => this.programLabel))
)
.pipe(
filter(isNotNilOrBlank),
).pipe(
filter(isNotNilOrBlank),

// DEBUG --
//tap(programLabel => console.debug('DEV - Getting programLabel=' + programLabel)),
// DEBUG --
//tap(programLabel => console.debug('DEV - Getting programLabel=' + programLabel)),

switchMap((programLabel) => this.programRefService.watchByLabel(programLabel, { debug: this.debug })),
catchError((err, _) => {
this.setError(err);
return Promise.resolve(null);
})
)
switchMap((programLabel) => this.programRefService.watchByLabel(programLabel, { debug: this.debug })),
catchError((err, _) => {
this.setError(err);
return Promise.resolve(null);
})
)
);
const programLoaded$ = this.program$
.pipe(
filter(isNotNil),
mergeMap((program) => this.setProgram(program)
const programLoaded$ = this.program$.pipe(
filter(isNotNil),
mergeMap((program) =>
this.setProgram(program)
.then(() => program)
.catch(err => {
.catch((err) => {
this.setError(err);
return undefined
}))
);
return undefined;
})
)
);

// Watch strategy
this._state.connect('strategy', programLoaded$.pipe(
combineLatestWith(merge(
this.strategyLabel$.pipe(distinctUntilChanged()),

// Allow to force reload (e.g. when strategy remotely changes - see startListenStrategyRemoteChanges() )
this._onStrategyReload.pipe(map(() => this.strategyLabel))))
this._state.connect(
'strategy',
programLoaded$
.pipe(
combineLatestWith(
merge(
this.strategyLabel$.pipe(distinctUntilChanged()),

// Allow to force reload (e.g. when strategy remotely changes - see startListenStrategyRemoteChanges() )
this._onStrategyReload.pipe(map(() => this.strategyLabel))
)
)
)
.pipe(
// DEBUG --
//tap(([_, strategyLabel]) => console.debug('DEV - Getting programLabel=' + strategyLabel)),

mergeMap(([program, strategyLabel]) => isNotNil(program) && isNotNilOrBlank(strategyLabel)
mergeMap(([program, strategyLabel]) =>
isNotNil(program) && isNotNilOrBlank(strategyLabel)
? this.strategyRefService.loadByLabel(strategyLabel, { programId: program.id })
: Promise.resolve(undefined)
),
Expand All @@ -183,11 +189,11 @@ export abstract class AppBaseDataEntityEditor<
)
);

this._state.hold(this.strategy$, strategy => this.setStrategy(strategy));
this._state.hold(this.strategy$, (strategy) => this.setStrategy(strategy));

if (!this.mobile) {
// Listen config
this._state.hold(this.configService.config, config => this.onConfigLoaded(config));
this._state.hold(this.configService.config, (config) => this.onConfigLoaded(config));
}
}

Expand Down Expand Up @@ -226,18 +232,28 @@ export abstract class AppBaseDataEntityEditor<
}

setError(error: string | AppErrorWithDetails, opts?: { emitEvent?: boolean; detailsCssClass?: string }) {
if (typeof error !== 'string' && error?.details?.errors) {
// Create a details message, from errors in forms (e.g. returned by control())
const formErrors = error.details.errors;
if (formErrors) {
const i18FormError = this.errorTranslator.translateErrors(formErrors, {
separator: ', ',
controlPathTranslator: this,
});
if (isNotNilOrBlank(i18FormError)) {
error.details.message = i18FormError;
if (error && typeof error !== 'string') {

// Convert form errors
if (error.details?.errors) {
// Create a details message, from errors in forms (e.g. returned by control())
const formErrors = error.details.errors;
if (formErrors) {
const i18FormError = this.errorTranslator.translateErrors(formErrors, {
separator: ', ',
controlPathTranslator: this,
});
if (isNotNilOrBlank(i18FormError)) {
error.details.message = i18FormError;
}
}
}

// Keep details message, if main message is the default message
if (error.message === 'COMMON.FORM.HAS_ERROR' && isNotNilOrBlank(error.details?.message)) {
error.message = error.details.message;
delete error.details;
}
}

super.setError(error, opts);
Expand Down Expand Up @@ -356,22 +372,21 @@ export abstract class AppBaseDataEntityEditor<
}
}

protected async openComposeMessageModal(recipient?: Person, opts?: {title?: string }) {
protected async openComposeMessageModal(recipient?: Person, opts?: { title?: string }) {
if (!this.canSendMessage) return; // Skip if disabled

console.debug('[base-data-editor] Writing a message to:', recipient);
const title = noHtml(opts?.title || this.titleSubject.value)?.toLowerCase();
const url = this.router.url;
const body = this.translate.instant('DATA.MESSAGE_BODY', {title, url})
const body = this.translate.instant('DATA.MESSAGE_BODY', { title, url });

await this.messageService.openComposeModal({
suggestFn: (value, filter) => this.personService.suggest(value, filter),
data: <Message>{
subject: title,
recipients: recipient ? [recipient] : [],
body
}
})
body,
},
});
}

}
4 changes: 2 additions & 2 deletions src/app/data/form/root-data-editor.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Program } from '@app/referential/services/model/program.model';
import { RootDataEntity } from '../services/model/root-data-entity.model';
import { UntypedFormControl } from '@angular/forms';
import { BaseRootDataService } from '@app/data/services/root-data-service.class';
import { AppBaseDataEntityEditor } from '@app/data/form/base-data-editor.class';
import { AppDataEntityEditor } from '@app/data/form/data-editor.class';

@Directive()
// tslint:disable-next-line:directive-class-suffix
Expand All @@ -25,7 +25,7 @@ export abstract class AppRootDataEntityEditor<
S extends BaseRootDataService<T, any, ID> = BaseRootDataService<T, any, any>,
ID = number
>
extends AppBaseDataEntityEditor<T, S, ID>
extends AppDataEntityEditor<T, S, ID>
implements OnInit, OnDestroy
{
protected programChangesSubscription: Subscription;
Expand Down
4 changes: 2 additions & 2 deletions src/app/data/measurement/measurements.form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ export class MeasurementsForm<S extends MeasurementsFormState = MeasurementsForm
const errorMsg = Object.keys(fieldErrors).map(errorKey => {
const key = 'ERROR.FIELD_' + errorKey.toUpperCase();
return this.translate.instant(key, fieldErrors[key]);
}).join(',');
}).join(', ');

return fieldName + ': ' + errorMsg;
}).join(',');
}).join(', ');
}

/**
Expand Down
Loading

0 comments on commit f87908f

Please sign in to comment.