From 2ee45515e9fa152057f8a4ec9ac7045de621cf8f Mon Sep 17 00:00:00 2001 From: Dragos-Paul Strat Date: Wed, 21 Aug 2024 17:44:36 +0300 Subject: [PATCH 1/3] wip 495 comm fixes --- .../src/assets/locales/ro/translation.json | 6 +++-- .../CreatableMultiSelect.tsx | 3 ++- frontend/src/index.css | 21 +++++++++------ .../components/AddApplicationConfig.ts | 13 ++++++--- .../apps-store/components/ApplicationForm.tsx | 14 ++++++---- .../components/ApplicationListTable.tsx | 27 +------------------ 6 files changed, 38 insertions(+), 46 deletions(-) diff --git a/frontend/src/assets/locales/ro/translation.json b/frontend/src/assets/locales/ro/translation.json index d25ead90..e8403538 100644 --- a/frontend/src/assets/locales/ro/translation.json +++ b/frontend/src/assets/locales/ro/translation.json @@ -48,7 +48,7 @@ "reset": "Resetează filtre", "show": "Filtre" }, - "unavailable": "În curând", + "unavailable": "Temporar indisponibilă", "to_be_removed": "De eliminat", "decimal": "Valori cu decimale nu sunt permise.", "unknown_error": "A apărut o eroare necunoscută", @@ -1065,6 +1065,7 @@ }, "status": { "label": "Status aplicație", + "required": "Statusul aplicației este obligatoriu", "options": { "active": "Activă (aplicația poate fi adăugată de organizații în profilul lor)", "disabled": "Inactivă (aplicația nu poate fi adăugată de organizații în profilul lor)" @@ -1111,7 +1112,8 @@ "application_label": { "label": "Eticheta pentru aplicație (eticheta apare în meniul Toate aplicațiile)", "helper": "Adaugă o etichetă deja existentă sau creează una nouă", - "maxLength": "Eticheta poate avea maxim 30 de caractere" + "maxLength": "Eticheta poate avea maxim 30 de caractere", + "minLength": "Eticheta poate avea minimum 2 de caractere" } }, "request_modal": { diff --git a/frontend/src/components/creatable-multi-select/CreatableMultiSelect.tsx b/frontend/src/components/creatable-multi-select/CreatableMultiSelect.tsx index b65e9847..0d98a919 100644 --- a/frontend/src/components/creatable-multi-select/CreatableMultiSelect.tsx +++ b/frontend/src/components/creatable-multi-select/CreatableMultiSelect.tsx @@ -71,9 +71,10 @@ const CreatableMultiSelect = ({ onChange={onChange} value={value} options={options} + isClearable id={id} formatCreateLabel={(text) => `${i18n.t('common:add_option')}: ${text}`} - isValidNewOption={validation ? validation : () => true} + isValidNewOption={(validation ? validation : () => true)} /> )} {!error && !readonly && helperText && ( diff --git a/frontend/src/index.css b/frontend/src/index.css index cd01e5a8..6387cbc9 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -176,21 +176,26 @@ transform: rotate(-45deg); position: absolute; background-color: #374159; - padding-top: 0.5rem; - padding-left: 3.5rem; - padding-bottom: 0.5rem; - padding-right: 4.5rem; + padding: 0.5rem 3.1rem; color: white; + width: 14rem; /* Adjust the width to fit text nicely */ + text-align: center; overflow: hidden; - width: 18rem; - margin-left: -0.5rem; + left: -3.5rem; /* Adjusted positioning */ + top: 2rem; /* Adjust as necessary */ + + @media screen and (max-width: 768px) { + width: 13rem; + } } .ribbon p { margin: 0; - white-space: normal; - overflow-wrap: break-word; + white-space: normal; /* Allow text to wrap */ + overflow-wrap: break-word; /* Handle long words */ + word-wrap: break-word; /* Ensure compatibility with older browsers */ text-align: center; + line-height: 1; /* Adjust line height to maintain readability */ } .richtext_html ul { diff --git a/frontend/src/pages/apps-store/components/AddApplicationConfig.ts b/frontend/src/pages/apps-store/components/AddApplicationConfig.ts index 74bae085..14e17e5e 100644 --- a/frontend/src/pages/apps-store/components/AddApplicationConfig.ts +++ b/frontend/src/pages/apps-store/components/AddApplicationConfig.ts @@ -20,6 +20,7 @@ const translations = { }, status: { label: i18n.t('appstore:config.status.label'), + required: i18n.t('appstore:config.status.required'), }, short: { required: i18n.t('appstore:config.short.required'), @@ -80,11 +81,11 @@ export const PullingTypeOptions = [ export function isHtmlContentEmpty(html: string): boolean { // Remove all HTML tags - const stripped = html.replace(/<[^>]*>/g, ''); + const stripped = html?.replace(/<[^>]*>/g, ''); // Remove whitespace - const trimmed = stripped.trim(); + const trimmed = stripped?.trim(); - return trimmed.length === 0; + return trimmed?.length === 0; } export const AddAppConfig: Record = { @@ -149,7 +150,7 @@ export const AddAppConfig: Record = { rules: { required: { value: true, - message: translations.type.required, + message: translations.status.required, }, }, helperText: '', @@ -173,6 +174,10 @@ export const AddAppConfig: Record = { value: 30, message: translations.short.max, }, + minLength: { + value: 2, + message: translations.short.max, + }, }, config: { type: 'text', diff --git a/frontend/src/pages/apps-store/components/ApplicationForm.tsx b/frontend/src/pages/apps-store/components/ApplicationForm.tsx index 9fb0140f..9091a03c 100644 --- a/frontend/src/pages/apps-store/components/ApplicationForm.tsx +++ b/frontend/src/pages/apps-store/components/ApplicationForm.tsx @@ -73,11 +73,15 @@ const ApplicationForm = ({ if (inputValue.length > 30 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { control.setError(AddAppConfig.applicationLabel.key, { type: 'maxLength', message: t('config.application_label.maxLength') }); return false; - } else if (inputValue.length > 30) { - return false; - } else if (inputValue.length < 30 && clearErrors && (errors as Record)[AddAppConfig.applicationLabel.key]) { + } else if (inputValue.length > 2 && inputValue.length < 30 && clearErrors && (errors as Record)[AddAppConfig.applicationLabel.key]) { clearErrors(AddAppConfig.applicationLabel.key); + return true + } else if (inputValue.length > 0 && inputValue.length < 3 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { + control.setError(AddAppConfig.applicationLabel.key, { type: 'minLength', message: t('config.application_label.minLength') }); + return false } + + console.log('inputValue', inputValue); return true; } @@ -286,7 +290,7 @@ const ApplicationForm = ({ )} {/* End Logo */} - {readonly &&
+
-
} +
{fields.map((item, index) => { diff --git a/frontend/src/pages/apps-store/components/ApplicationListTable.tsx b/frontend/src/pages/apps-store/components/ApplicationListTable.tsx index 6613c7c8..465a670b 100644 --- a/frontend/src/pages/apps-store/components/ApplicationListTable.tsx +++ b/frontend/src/pages/apps-store/components/ApplicationListTable.tsx @@ -8,13 +8,11 @@ import { OrderDirection } from '../../../common/enums/sort-direction.enum'; import { useErrorToast } from '../../../common/hooks/useToast'; import DataTableFilters from '../../../components/data-table-filters/DataTableFilters'; import DataTableComponent from '../../../components/data-table/DataTableComponent'; -import PopoverMenu, { PopoverMenuRowType } from '../../../components/popover-menu/PopoverMenu'; import Select from '../../../components/Select/Select'; import { useApplicationsQuery, } from '../../../services/application/Application.queries'; import { - Application, ApplicationStatus, } from '../../../services/application/interfaces/Application.interface'; import { useApplications } from '../../../store/selectors'; @@ -63,29 +61,6 @@ const ApplicationListTable = () => { }, [error]); - const buildUserActionColumn = (): TableColumn => { - - const activeApplicationMenu = [ - { - name: t('list.view'), - icon: EyeIcon, - onClick: onView, - type: PopoverMenuRowType.INFO, - }, - ]; - - return { - name: '', - cell: (row: Application) => ( - - ), - width: '50px', - allowOverflow: true, - }; - }; const onRowsPerPageChange = (rows: number) => { setRowsPerPage(rows); @@ -165,7 +140,7 @@ const ApplicationListTable = () => {

Date: Thu, 22 Aug 2024 12:04:46 +0300 Subject: [PATCH 2/3] feat: [495-1] fix comments --- .../application/dto/create-application.dto.ts | 4 +++ .../application/dto/update-application.dto.ts | 5 ---- .../services/application.service.ts | 8 ++++++ .../services/ong-application.service.ts | 5 ++++ .../apps-store/components/ApplicationForm.tsx | 25 ++++++++++++++----- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/backend/src/modules/application/dto/create-application.dto.ts b/backend/src/modules/application/dto/create-application.dto.ts index 78a303fe..2262a92b 100644 --- a/backend/src/modules/application/dto/create-application.dto.ts +++ b/backend/src/modules/application/dto/create-application.dto.ts @@ -11,6 +11,7 @@ import { REGEX } from 'src/common/constants/patterns.constant'; import { ApplicationPullingType } from '../enums/application-pulling-type.enum'; import { ApplicationTypeEnum } from '../enums/ApplicationType.enum'; import { ApplicationLabel } from 'src/shared/entities/application-labels.entity'; +import { ApplicationStatus } from '../enums/application-status.enum'; export class CreateApplicationDto { @IsString() @@ -60,4 +61,7 @@ export class CreateApplicationDto { @IsOptional() applicationLabel: Partial; + + @IsEnum(ApplicationStatus) + status: ApplicationStatus; } diff --git a/backend/src/modules/application/dto/update-application.dto.ts b/backend/src/modules/application/dto/update-application.dto.ts index ce20eaaa..71973a8b 100644 --- a/backend/src/modules/application/dto/update-application.dto.ts +++ b/backend/src/modules/application/dto/update-application.dto.ts @@ -1,15 +1,10 @@ import { PartialType, OmitType } from '@nestjs/swagger'; import { IsEnum, IsOptional } from 'class-validator'; -import { ApplicationStatus } from '../enums/application-status.enum'; import { CreateApplicationDto } from './create-application.dto'; export class UpdateApplicationDto extends PartialType( OmitType(CreateApplicationDto, ['type']), ) { - @IsEnum(ApplicationStatus) - @IsOptional() - status?: ApplicationStatus; - @IsOptional() cognitoClientId?: string; } diff --git a/backend/src/modules/application/services/application.service.ts b/backend/src/modules/application/services/application.service.ts index 90d5ef35..29787562 100644 --- a/backend/src/modules/application/services/application.service.ts +++ b/backend/src/modules/application/services/application.service.ts @@ -73,9 +73,17 @@ export class ApplicationService { }; } + let applicationLabel = null; + if (createApplicationDto.applicationLabel) { + applicationLabel = await this.saveAndGetApplicationLabel( + createApplicationDto.applicationLabel, + ); + } + // 3. save the app return this.applicationRepository.save({ ...createApplicationDto, + applicationLabel, }); } catch (error) { this.logger.error({ diff --git a/backend/src/modules/application/services/ong-application.service.ts b/backend/src/modules/application/services/ong-application.service.ts index 31c101c3..aea1db8a 100644 --- a/backend/src/modules/application/services/ong-application.service.ts +++ b/backend/src/modules/application/services/ong-application.service.ts @@ -132,6 +132,11 @@ export class OngApplicationService { 'ongApp.applicationId = application.id AND ongApp.organizationId = :organizationId', { organizationId }, ) + .leftJoin( + '_application-label', + 'applicationLabel', + 'applicationLabel.id = application.application_label_id', + ) .where( 'ongApp.organizationId = :organizationId and ongApp.status != :status', { diff --git a/frontend/src/pages/apps-store/components/ApplicationForm.tsx b/frontend/src/pages/apps-store/components/ApplicationForm.tsx index 9091a03c..9fa29587 100644 --- a/frontend/src/pages/apps-store/components/ApplicationForm.tsx +++ b/frontend/src/pages/apps-store/components/ApplicationForm.tsx @@ -72,16 +72,29 @@ const ApplicationForm = ({ const ribbonValidation = (inputValue: string) => { if (inputValue.length > 30 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { control.setError(AddAppConfig.applicationLabel.key, { type: 'maxLength', message: t('config.application_label.maxLength') }); + } + + if (inputValue.length > 30) { return false; - } else if (inputValue.length > 2 && inputValue.length < 30 && clearErrors && (errors as Record)[AddAppConfig.applicationLabel.key]) { - clearErrors(AddAppConfig.applicationLabel.key); - return true - } else if (inputValue.length > 0 && inputValue.length < 3 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { + } + + + if (inputValue.length > 2 && inputValue.length < 30 && (errors as Record)[AddAppConfig.applicationLabel.key]) { + clearErrors && clearErrors(AddAppConfig.applicationLabel.key); + } + + if (inputValue.length > 2 && inputValue.length < 30) { + return true; + } + + if (inputValue.length && inputValue.length < 3 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { control.setError(AddAppConfig.applicationLabel.key, { type: 'minLength', message: t('config.application_label.minLength') }); - return false } - console.log('inputValue', inputValue); + if (inputValue.length < 3) { + return false; + } + return true; } From f96b891718031178c7839820da0144936f58441a Mon Sep 17 00:00:00 2001 From: Dragos-Paul Strat Date: Thu, 22 Aug 2024 13:39:00 +0300 Subject: [PATCH 3/3] feat: [495-1] fix comments for PR --- .../src/pages/apps-store/components/ApplicationForm.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/apps-store/components/ApplicationForm.tsx b/frontend/src/pages/apps-store/components/ApplicationForm.tsx index 9fa29587..188984ea 100644 --- a/frontend/src/pages/apps-store/components/ApplicationForm.tsx +++ b/frontend/src/pages/apps-store/components/ApplicationForm.tsx @@ -70,7 +70,9 @@ const ApplicationForm = ({ }; const ribbonValidation = (inputValue: string) => { - if (inputValue.length > 30 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { + const labelError = (errors as Record)[AddAppConfig.applicationLabel.key]; + + if (inputValue.length > 30 && !labelError) { control.setError(AddAppConfig.applicationLabel.key, { type: 'maxLength', message: t('config.application_label.maxLength') }); } @@ -79,7 +81,7 @@ const ApplicationForm = ({ } - if (inputValue.length > 2 && inputValue.length < 30 && (errors as Record)[AddAppConfig.applicationLabel.key]) { + if (inputValue.length > 2 && inputValue.length < 30 && labelError) { clearErrors && clearErrors(AddAppConfig.applicationLabel.key); } @@ -87,7 +89,7 @@ const ApplicationForm = ({ return true; } - if (inputValue.length && inputValue.length < 3 && !(errors as Record)[AddAppConfig.applicationLabel.key]) { + if (inputValue.length && inputValue.length < 3 && !labelError) { control.setError(AddAppConfig.applicationLabel.key, { type: 'minLength', message: t('config.application_label.minLength') }); }