Fix #478 - Add Currency Edit Component

This commit is contained in:
Jack Anderson 2024-07-11 14:15:51 +01:00 committed by y.yerli
parent de1c91b086
commit 3d9fcc190e
4 changed files with 153 additions and 0 deletions

View file

@ -46,6 +46,7 @@ import {BooleanDetailFieldComponent} from './boolean/templates/detail/boolean.co
import {EmailListFieldsModule} from './email/templates/list/email.module';
import {VarcharFilterFieldComponent} from './varchar/templates/filter/filter.component';
import {CurrencyDetailFieldComponent} from './currency/templates/detail/currency.component';
import {CurrencyEditFieldComponent} from './currency/templates/edit/currency.component';
import {EnumEditFieldModule} from './enum/templates/edit/enum.module';
import {MultiEnumDetailFieldModule} from './multienum/templates/detail/multienum.module';
import {FileDetailFieldModule} from './file/templates/detail/file.module';
@ -107,6 +108,7 @@ import {IconListFieldModule} from "./icon/templates/detail/icon.module";
import {IconDetailFieldComponent} from "./icon/templates/detail/icon.component";
import {TextListFieldModule} from './text/templates/list/text.module';
import {TextListFieldComponent} from './text/templates/list/text.component';
import {CurrencyEditFieldModule} from "./currency/templates/edit/currency.module";
export const baseFieldModules = [
VarcharDetailFieldModule,
@ -127,6 +129,7 @@ export const baseFieldModules = [
DateTimeFilterFieldModule,
UrlDetailFieldModule,
CurrencyDetailFieldModule,
CurrencyEditFieldModule,
EmailListFieldsModule,
TextDetailFieldModule,
TextEditFieldModule,
@ -170,6 +173,7 @@ export const baseFieldComponents = [
UrlDetailFieldComponent,
IconDetailFieldComponent,
CurrencyDetailFieldComponent,
CurrencyEditFieldComponent,
EmailListFieldsComponent,
TextDetailFieldComponent,
TextEditFieldComponent,
@ -230,6 +234,7 @@ export const baseViewFieldsMap: FieldComponentMap = {
'link.detail': UrlDetailFieldComponent,
'currency.list': CurrencyDetailFieldComponent,
'currency.detail': CurrencyDetailFieldComponent,
'currency.edit': CurrencyEditFieldComponent,
'email.list': EmailListFieldsComponent,
'email.detail': EmailListFieldsComponent,
'text.detail': TextDetailFieldComponent,

View file

@ -0,0 +1,32 @@
<! --
/**
* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
* Copyright (C) 2024 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Supercharged by SuiteCRM".
*/
-->
<input #currencyField [class.is-invalid]="field.formControl.invalid && field.formControl.touched"
[(ngModel)]="value"
[formControl]="field.formControl"
[ngClass]="klass"
type="text">

View file

@ -0,0 +1,68 @@
/**
* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
* Copyright (C) 2024 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Supercharged by SuiteCRM".
*/
import {OnInit, Component, ElementRef, ViewChild} from '@angular/core';
import {BaseNumberComponent} from '../../../base/base-number.component';
import {SystemConfigStore} from '../../../../store/system-config/system-config.store';
import {DataTypeFormatter} from '../../../../services/formatters/data-type.formatter.service';
import {UserPreferenceStore} from '../../../../store/user-preference/user-preference.store';
import {FormatOptions} from '../../../../services/formatters/formatter.model';
import {FieldLogicManager} from '../../../field-logic/field-logic.manager';
import {FieldLogicDisplayManager} from '../../../field-logic-display/field-logic-display.manager';
@Component({
selector: 'scrm-currency-edit',
templateUrl: './currency.component.html',
styleUrls: []
})
export class CurrencyEditFieldComponent extends BaseNumberComponent implements OnInit {
@ViewChild('currencyField') currencyField: ElementRef;
value: string;
constructor(
protected userPreferences: UserPreferenceStore,
protected systemConfig: SystemConfigStore,
protected typeFormatter: DataTypeFormatter,
protected logic: FieldLogicManager,
protected logicDisplay: FieldLogicDisplayManager
) {
super(userPreferences, systemConfig, typeFormatter, logic, logicDisplay);
}
ngOnInit(): void {
super.ngOnInit();
this.subscribeValueChanges();
this.value = this.typeFormatter.toUserFormat(this.field.type, this.field.value, this.getOptions());
}
getOptions(): FormatOptions {
return {
mode: 'edit'
} as FormatOptions;
}
}

View file

@ -0,0 +1,48 @@
/**
* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
* Copyright (C) 2024 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Supercharged by SuiteCRM".
*/
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {CurrencyEditFieldComponent} from './currency.component';
import {FormatCurrencyModule} from '../../../../pipes/format-currency/format-currency.module';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {LabelModule} from '../../../../components/label/label.module';
import {NgbModule} from "@ng-bootstrap/ng-bootstrap";
@NgModule({
declarations: [CurrencyEditFieldComponent],
exports: [CurrencyEditFieldComponent],
imports: [
CommonModule,
FormatCurrencyModule,
FormsModule,
ReactiveFormsModule,
LabelModule,
NgbModule
]
})
export class CurrencyEditFieldModule {
}