Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MiRo1310 committed Sep 28, 2024
1 parent 9175f94 commit 167ab09
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
13 changes: 8 additions & 5 deletions admin/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export interface RowsNav {

export interface PropsTabAction {
data: DataMainContent
callback: Callback;
callback: CallbackFunctionsApp;
}

export interface Data {
Expand Down Expand Up @@ -334,7 +334,7 @@ export interface PropsActionCard {
data: DataMainContent & { tab: TabValues }
card: string;
showButtons: ShowButtons;
callback: CallbackFunctions;
callback: CallbackFunctionsApp;
}
interface ShowButtons {
add: boolean;
Expand Down Expand Up @@ -370,7 +370,7 @@ export interface PropsTableDndAction {
setState: SetStateFunction;
showButtons: ShowButtons;
openAddRowCard: any;
callback: CallbackFunctions;
callback: CallbackFunctionsApp;
addEditedTrigger: any;
card: string;
}
Expand Down Expand Up @@ -449,8 +449,11 @@ export interface PropsRowEditPopupCard {
searchRoot: SearchRoot | null | undefined;
buttons: PopupCardButtons;
newUnUsedTrigger: string[];
callback?: { setState: SetStateFunction };
callbackFromAppTsx: CallbackFunctions;
callback: CallbackFunctionsApp & CallbackTabActionContent;
}

export interface CallbackTabActionContent {
setStateTabActionContent: SetStateFunction;
}

export type BooleanString = "true" | "false";
Expand Down
13 changes: 4 additions & 9 deletions admin/src/pages/AppContentTabAction.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from "react";
import { TabContext, TabPanel } from "@mui/lab";
import ActionCard from "./AppContentTabActionContent";
import AppContentTabActionContent from "./AppContentTabActionContent";
import { tabValues } from "../config/entries";
import TabActionTabs from "./AppContentTabActionTabsListing";
import AppContentTabActionTabsListing from "./AppContentTabActionTabsListing";
import { PropsTabAction, StateTabAction } from "admin/app";

class TabAction extends Component<PropsTabAction, StateTabAction> {
Expand All @@ -16,19 +16,14 @@ class TabAction extends Component<PropsTabAction, StateTabAction> {
render() {
return (
<TabContext value={this.state.value}>
<TabActionTabs callback={this.props.callback} setState={this.setState.bind(this)} />
<AppContentTabActionTabsListing callback={this.props.callback} setState={this.setState.bind(this)} />
{tabValues.map((tab, index) => (
<TabPanel key={index} value={tab.value} className="TabPanel-Action">
<ActionCard
<AppContentTabActionContent
callback={this.props.callback}
data={{ ...this.props.data, tab }}
card="action"
// subCard={tab.value}
// entries={tab.entries}
// searchRoot={tab.searchRoot ? tab.searchRoot : null}
// titlePopup={tab.label}
showButtons={{ add: true, remove: true, edit: true }}
// popupCard={tab.popupCard}
/>
</TabPanel>
))}
Expand Down
18 changes: 6 additions & 12 deletions admin/src/pages/AppContentTabActionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ class ActionCard extends Component<PropsActionCard, StateActionCard> {
}
}
}
//TODO - Doppelte Funktion
if (prevProps.data !== this.props.data) {
this.getLengthOfData(native.data.action, activeMenu);
}
if (activeMenu !== prevProps.data.state.activeMenu) {

if (prevProps.data !== this.props.data || activeMenu !== prevProps.data.state.activeMenu) {
this.getLengthOfData(native.data.action, activeMenu);
}

Expand All @@ -58,15 +55,13 @@ class ActionCard extends Component<PropsActionCard, StateActionCard> {
}
checkNewValueIsOK = () => {
if (
this.state.editedValueFromHelperText !== null &&
this.state.editedValueFromHelperText !== undefined &&
this.state.editedValueFromHelperText &&
this.state.editedValueFromHelperText !== "" &&
this.state.editedValueFromHelperText !== this.state[this.state.helperTextFor]
) {
return true;
} else {
return false;
}
return false;
};
addEditedTrigger = (trigger) => {
let newTriggerArray: string[] = [];
Expand Down Expand Up @@ -149,12 +144,12 @@ class ActionCard extends Component<PropsActionCard, StateActionCard> {
});
this.setState({ newRow: newRow });
};

getLengthOfData = (data: ActionData, activeMenu: string) => {
const { value: subCard } = this.props.data.tab;

if (data?.[activeMenu]?.[subCard]?.length) {
this.setState({ rowsLength: data[activeMenu][subCard].length });
console.log("rowsLength", this.state.rowsLength);
return;
}
this.setState({ rowsLength: 0 });
Expand Down Expand Up @@ -245,8 +240,7 @@ class ActionCard extends Component<PropsActionCard, StateActionCard> {
<AppContentTabActionContentRowEditor
data={this.props.data}
newRow={this.state.newRow}
callback={{ setState: this.setState.bind(this) }}
callbackFromAppTsx={this.props.callback}
callback={{ ...this.props.callback, setStateTabActionContent: this.setState.bind(this) }}
entries={this.props.data.tab.entries}
searchRoot={this.props.data.tab.searchRoot}
newUnUsedTrigger={this.state.newUnUsedTrigger || this.props.data.state.unUsedTrigger}
Expand Down
2 changes: 1 addition & 1 deletion admin/src/pages/AppContentTabActionContentRowEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class RowEditPopupCard extends Component<PropsRowEditPopupCard, StateRowEditPopu
rows={(this, this.state.rows)}
newRow={this.props.newRow}
setState={this.setState.bind(this)}
callbackFromAppTsx={this.props.callbackFromAppTsx}
callback={this.props.callback}
data={this.props.data}
/>
</TableRow>
Expand Down
2 changes: 1 addition & 1 deletion admin/src/pages/AppContentTabActionContentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class TableDndAction extends Component<PropsTableDndAction, StateTableDndAction>
event,
this.state.mouseOverNoneDraggable,
this.setState.bind(this),
this.props.callback.setState({ draggingRowIndex: index }),
this.props.callback.setStateApp({ draggingRowIndex: index }),
);
}}
onDragEnd={() => handleDragEnd(this.setState.bind(this), this.props)}
Expand Down
7 changes: 4 additions & 3 deletions admin/src/pages/AppContentTabActionTabsListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Box, Tab } from "@mui/material";
import { TabList } from "@mui/lab";
import { tabValues } from "@/config/entries";
import { CallbackFunctions } from "admin/app";
import { CallbackFunctionsApp } from "../../app";
interface PropsTabActionTabs {
callback: CallbackFunctions;
callback: CallbackFunctionsApp;
setState: ({}) => void;
}

Expand All @@ -14,8 +15,8 @@ class TabActionTabs extends Component<PropsTabActionTabs> {
this.state = {};
}
handleChange = (event, newValue) => {
if (this.props.callback.setState) {
this.props.callback.setState({ subTab: newValue });
if (this.props.callback.setStateApp) {
this.props.callback.setStateApp({ subTab: newValue });
}
this.props.setState({ value: newValue });
};
Expand Down
4 changes: 2 additions & 2 deletions admin/src/types/props-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RowsSetState, TabValueEntries, ActionNewRowProps, Data, CallbackFunctionsApp, Socket, DataMainContent } from '../../app';
import { RowsSetState, TabValueEntries, ActionNewRowProps, Data, CallbackFunctionsApp, Socket, DataMainContent, CallbackTabActionContent } from '../../app';
import { SetStateFunction, PopupCardButtons, CallbackFunctions, AdditionalStateInfo } from 'admin/app';
export interface AppContentTabActionContentRowEditorButtonsProps {
buttons: PopupCardButtons;
Expand All @@ -8,7 +8,7 @@ export interface AppContentTabActionContentRowEditorButtonsProps {
rows: RowsSetState[];
setState: SetStateFunction;
data: Data
callbackFromAppTsx: CallbackFunctions;
callback: CallbackFunctionsApp & CallbackTabActionContent;
}

export interface PropsMainTabs {
Expand Down

0 comments on commit 167ab09

Please sign in to comment.