Skip to content

Commit

Permalink
feat: Added properties disableFindAndReplace,disableCheckBox and disa… (
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismayuresh authored and Mayur committed Jan 3, 2025
2 parents 2a13c50 + c0f04ed commit 26a6f5c
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 48 deletions.
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/api",
"version": "0.27.3",
"version": "0.27.4",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/queue-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/queue-manager",
"version": "0.27.3",
"version": "0.27.4",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/web",
"version": "0.27.3",
"version": "0.27.4",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/widget",
"version": "0.27.3",
"version": "0.27.4",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 2 additions & 0 deletions apps/widget/src/components/Common/Container/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function Container({ children }: PropsWithChildren<{}>) {
colorScheme: data.value.colorScheme,
title: data.value.title,
texts: deepMerge(WIDGET_TEXTS, data.value.texts),
config: data.value.config,
schema:
typeof data.value.schema === 'string'
? data.value.schema
Expand Down Expand Up @@ -330,6 +331,7 @@ export function Container({ children }: PropsWithChildren<{}>) {
schema={secondaryPayload?.schema}
title={secondaryPayload?.title}
texts={secondaryPayload.texts as typeof WIDGET_TEXTS}
config={secondaryPayload.config}
// api
api={api}
// impler-context
Expand Down
5 changes: 4 additions & 1 deletion apps/widget/src/components/Common/Provider/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropsWithChildren } from 'react';
import { ApiService } from '@api';
import { WIDGET_TEXTS } from '@impler/client';
import { WIDGET_TEXTS, WidgetConfig } from '@impler/client';
import APIContextProvider from '@store/api.context';
import AppContextProvider from '@store/app.context';
import { JobsInfoProvider } from '@store/jobinfo.context';
Expand All @@ -10,6 +10,7 @@ interface IProviderProps {
// app-context
title?: string;
texts: typeof WIDGET_TEXTS;
config?: WidgetConfig;
primaryColor: string;
output?: string;
sampleFile?: File | Blob;
Expand All @@ -31,6 +32,7 @@ export function Provider(props: PropsWithChildren<IProviderProps>) {
const {
api,
data,
config,
title,
sampleFile,
texts,
Expand Down Expand Up @@ -61,6 +63,7 @@ export function Provider(props: PropsWithChildren<IProviderProps>) {
data={data}
title={title}
sampleFile={sampleFile}
config={config}
texts={texts}
output={output}
schema={schema}
Expand Down
21 changes: 12 additions & 9 deletions apps/widget/src/components/Common/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ interface TableProps {
onCheckAll?: (checked: boolean) => void;
onValueChange?: (row: number, prop: string, oldVal: any, newVal: any) => void;
onRowCheck?: (rowIndex: number, recordIndex: number, checked: boolean) => void;
disableCheckBox?: boolean;
}

export const Table = forwardRef<HotTableClass, TableProps>(
Expand All @@ -182,6 +183,7 @@ export const Table = forwardRef<HotTableClass, TableProps>(
headings,
columnDefs,
data,
disableCheckBox,
beforePaste,
columnDescriptions,
allChecked,
Expand All @@ -191,7 +193,8 @@ export const Table = forwardRef<HotTableClass, TableProps>(
minSpareRows,
frozenColumns = 2,
onValueChange,
selectEnabled = true,
// Conditionally set selectEnabled based on disableCheckBox
selectEnabled = disableCheckBox === undefined ? true : !disableCheckBox,
}: TableProps,
gridRef
) => {
Expand Down Expand Up @@ -244,15 +247,15 @@ export const Table = forwardRef<HotTableClass, TableProps>(

if (!selectEnabled && i < 0) {
TH.innerHTML = '#';
} else if (selectEnabled && i === 0) {
TH.classList.add('check-all-cell');
} else if (selectEnabled && i === 0 && selectEnabled) {
TH.innerHTML = `
<div class="checkbox">
<input type="checkbox" ${allChecked ? 'checked' : ''} class="checkbox__control">
<svg class="checkbox__control-icon" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24">
<path fill="currentColor" d="M 20.292969 5.2929688 L 9 16.585938 L 4.7070312 12.292969 L 3.2929688 13.707031 L 9 19.414062 L 21.707031 6.7070312 L 20.292969 5.2929688 z"></path>
</svg>
</div>`;
<div class="checkbox">
<input type="checkbox" ${allChecked ? 'checked' : ''} class="checkbox__control">
<svg class="checkbox__control-icon" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24">
<path fill="currentColor" d="M 20.292969 5.2929688 L 9 16.585938 L 4.7070312 12.292969 L 3.2929688 13.707031 L 9 19.414062 L 21.707031 6.7070312 L 20.292969 5.2929688 z"></path>
</svg>
</div>
`;
} else {
if (columnDescriptions && columnDescriptions[i]) {
// Create the SVG icon element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function AutoImportPhase3({ onNextClick }: IAutoImportPhase3Props) {
<Tabs.List>
{autoImportSchedulerFrequency.map((type) => (
<Tabs.Tab key={type} value={type}>
{type.charAt(0).toUpperCase() + type.slice(1)}
<Text size="md">{type.charAt(0).toUpperCase() + type.slice(1)}</Text>
</Tabs.Tab>
))}
</Tabs.List>
Expand Down
8 changes: 6 additions & 2 deletions apps/widget/src/components/widget/Phases/Phase3/Phase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export function Phase3(props: IPhase3Props) {
isCompleteImportLoading,
setShowAllDataValidModal,
setShowDeleteConfirmModal,
disableFindAndReplace,
disableCheckBox,
} = usePhase3({ onNext: onNextClick });
const tableWrapperRef = useRef<HTMLDivElement>() as React.MutableRefObject<HTMLDivElement>;
const [tableWrapperDimensions, setTableWrapperDimentions] = useState({
Expand All @@ -70,7 +72,6 @@ export function Phase3(props: IPhase3Props) {
const columnDescriptions = columnDefs.map((column) => column.description || '');

useEffect(() => {
// setting wrapper height
setTableWrapperDimentions({
height: tableWrapperRef.current.getBoundingClientRect().height - 50,
width: tableWrapperRef.current.getBoundingClientRect().width,
Expand Down Expand Up @@ -115,7 +116,9 @@ export function Phase3(props: IPhase3Props) {
]}
/>
<Group spacing="xs">
<Button onClick={() => setShowFindReplaceModal(true)}>{texts.PHASE3.FIND_REPLACE}</Button>
{!disableFindAndReplace && (
<Button onClick={() => setShowFindReplaceModal(true)}>{texts.PHASE3.FIND_REPLACE}</Button>
)}
<Button
color="red"
disabled={!selectedRowsRef.current.size}
Expand Down Expand Up @@ -202,6 +205,7 @@ export function Phase3(props: IPhase3Props) {
columnDefs={columnDefs}
allChecked={allChecked}
columnDescriptions={columnDescriptions}
disableCheckBox={disableCheckBox}
/>
</Stack>
<Pagination page={page} total={totalPages} onChange={onPageChange} />
Expand Down
50 changes: 31 additions & 19 deletions apps/widget/src/hooks/Phase3/usePhase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
valid: new Set(),
invalid: new Set(),
});
const { uploadInfo, setUploadInfo } = useAppState();
const { uploadInfo, setUploadInfo, config } = useAppState();
const [allChecked, setAllChecked] = useState<boolean>(false);
const [reviewData, setReviewData] = useState<IRecordExtended[]>([]);
const [columnDefs, setColumnDefs] = useState<HotItemSchema[]>([]);
Expand All @@ -60,26 +60,36 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
() => api.getColumns(uploadInfo._id),
{
onSuccess(data) {
let updatedFrozenColumns = 2;
let updatedFrozenColumns = 0;
const dataColumns: IOption[] = [{ value: '', label: 'All columns' }];
const newColumnDefs: HotItemSchema[] = [];
const newHeadings: string[] = ['*', 'Sr. No.'];
newColumnDefs.push({
type: 'text',
data: 'record.index',
readOnly: true,
editor: false,
renderer: 'check',
className: 'check-cell',
disableVisualSelection: true,
});
newColumnDefs.push({
type: 'text',
data: 'index',
readOnly: true,
className: 'index-cell',
disableVisualSelection: true,
});
const newHeadings: string[] = [];

if (!config?.disableCheckBox) {
newHeadings.push('*');
updatedFrozenColumns++;
newColumnDefs.push({
type: 'text',
data: 'record.index',
readOnly: true,
editor: false,
renderer: 'check',
className: 'check-cell',
disableVisualSelection: true,
});
}

if (!config?.disableSrNo) {
newHeadings.push('Sr. No.');
updatedFrozenColumns++;
newColumnDefs.push({
type: 'text',
data: 'index',
readOnly: true,
className: 'index-cell',
disableVisualSelection: true,
});
}
data.forEach((column: ISchemaColumn) => {
if (column.isFrozen) updatedFrozenColumns++;
newHeadings.push(column.name);
Expand Down Expand Up @@ -294,5 +304,7 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
totalRecords: uploadInfo.totalRecords ?? undefined,
invalidRecords: uploadInfo.invalidRecords ?? undefined,
refetchReviewData: () => refetchReviewData([page, type]),
disableFindAndReplace: config?.disableFindAndReplace,
disableCheckBox: config?.disableCheckBox,
};
}
2 changes: 2 additions & 0 deletions apps/widget/src/store/app.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const AppContextProvider = ({
primaryColor,
title,
texts,
config,
data,
sampleFile,
schema,
Expand All @@ -55,6 +56,7 @@ const AppContextProvider = ({
value={{
title,
texts,
config,
host,
reset,
data,
Expand Down
3 changes: 2 additions & 1 deletion apps/widget/src/types/store.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiService } from '@api';
import { Dispatch, SetStateAction } from 'react';
import { IUpload, WIDGET_TEXTS } from '@impler/client';
import { IUpload, WIDGET_TEXTS, WidgetConfig } from '@impler/client';
import { ITemplate, IImportConfig } from '@impler/shared';

export interface IImplerStore {
Expand Down Expand Up @@ -29,6 +29,7 @@ export enum FlowsEnum {
export interface IAppStore {
title?: string;
texts: typeof WIDGET_TEXTS;
config?: WidgetConfig;
importId?: string;
imageSchema?: string;
data?: string;
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"libs/*",
"packages/*"
],
"version": "0.27.3"
"version": "0.27.4"
}
2 changes: 1 addition & 1 deletion libs/dal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/dal",
"version": "0.27.3",
"version": "0.27.4",
"author": "implerhq",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion libs/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/embed",
"version": "0.27.3",
"version": "0.27.4",
"private": true,
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/services/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/services",
"version": "0.27.3",
"version": "0.27.4",
"description": "Reusable services to shared between backend api and queue-manager",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/shared",
"version": "0.27.3",
"version": "0.27.4",
"description": "Reusable types and classes to shared between apps and libraries",
"license": "MIT",
"author": "implerhq",
Expand Down
4 changes: 3 additions & 1 deletion libs/shared/src/types/widget/widget.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WIDGET_TEXTS } from '@impler/client';
import { WIDGET_TEXTS, WidgetConfig } from '@impler/client';
import { ISchemaItem } from '../column';

export interface ICommonShowPayload {
Expand All @@ -16,13 +16,15 @@ export interface ICommonShowPayload {
}
export interface IWidgetShowPayload extends ICommonShowPayload {
texts?: typeof WIDGET_TEXTS;
config?: WidgetConfig;
data?: string;
schema?: string;
output?: string;
}

export interface IUserShowPayload extends ICommonShowPayload {
texts?: string | typeof WIDGET_TEXTS;
config?: WidgetConfig;
data?: string | Record<string, string | number>[];
schema?: string | ISchemaItem[];
output?: string | Record<string, string | number>;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/angular",
"version": "0.27.3",
"version": "0.27.4",
"description": "Angular library to show CSV Excel Importer in angular applications",
"license": "MIT",
"author": "implerhq",
Expand Down Expand Up @@ -52,6 +52,6 @@
"typescript": "^4.4.4"
},
"dependencies": {
"@impler/client": "^0.27.3"
"@impler/client": "^0.27.4"
}
}
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/client",
"version": "0.27.3",
"version": "0.27.4",
"description": "API client to be used in end user environments",
"license": "MIT",
"author": "implerhq",
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export interface IShowWidgetProps {
accessToken: string;
sampleFile?: File | Blob;
texts?: CustomTexts;
config?: WidgetConfig;
title?: string;
primaryColor?: string;
extra?: string | Record<string, any>;
Expand All @@ -179,6 +180,12 @@ export type DeepPartial<T> = T extends object

export type ValueOf<T> = T[keyof T];

export declare type WidgetConfig = {
disableFindAndReplace?: boolean;
disableCheckBox?: boolean;
disableSrNo?: boolean;
};

export type CustomTexts = DeepPartial<typeof WIDGET_TEXTS>;

export interface IUseImplerProps {
Expand All @@ -189,6 +196,7 @@ export interface IUseImplerProps {
accessToken?: string;
primaryColor?: string;
extra?: string | Record<string, any>;
config?: WidgetConfig;
authHeaderValue?: string | (() => string) | (() => Promise<string>);
onUploadStart?: (value: UploadTemplateData) => void;
onUploadTerminate?: (value: UploadData) => void;
Expand Down
Loading

0 comments on commit 26a6f5c

Please sign in to comment.