Skip to content

Commit

Permalink
modified the code to avoid deleting all the wrappers in the list. Whe…
Browse files Browse the repository at this point in the history
…n you only have one item in a list, you cannot delete it anymore
  • Loading branch information
danielc-n committed Sep 26, 2024
1 parent c67ba5d commit b5091ea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion renderer/src/layouts/editor/InnerFramePopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ export default function InnerFramePopup() {
</TextOnlyTooltip>
</div>
<ul className="sortable-TESTWRAPPER-list">
{Object.keys(selected).map((k) => (
{Object.keys(selected).map((k,i,arraySel) => (
<li
id={k}
className="sortable-test1-item"
Expand All @@ -719,6 +719,7 @@ export default function InnerFramePopup() {
advanceMode={advanceMode}
changePrintData={setSelected}
changePrintOrder={setOrderSelection}
showTrashButton={arraySel.length > 1}
/>
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function BCVWrapperSortableList({
fontWeight: 600,
}}
>
For each book selected above
Loop mode
</div>
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function JXLHeaderWrapper({
fontWeight: 600,
}}
>
For each book selected above
Loop mode
</div>
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function OBSWrapperSortableList({
/>
</div>

<div style={{ display: 'flex', justifyContent: 'end' }}>
<div style={{ display: 'flex', justifyContent: 'left' }}>
{advanceMode ? (
<div>
<TextOnlyTooltip
Expand All @@ -118,7 +118,7 @@ export function OBSWrapperSortableList({
fontWeight: 600,
}}
>
For each Obs selected above
Loop mode
</div>
<div
style={{
Expand Down Expand Up @@ -152,7 +152,6 @@ export function OBSWrapperSortableList({
) : (
<div />
)}

</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function WrapperTemplate({
advanceMode,
changePrintData,
changePrintOrder,
showTrashButton,
}) {
const [orderSections, setOrderSelections] = useState([0]);
const updateElemOrder = (items) => {
Expand All @@ -63,6 +64,7 @@ export function WrapperTemplate({
} else {
ret = 'null';
}
console.log(Object.keys(parseSection));
} catch {
ret = 'null';
}
Expand All @@ -73,10 +75,11 @@ export function WrapperTemplate({
};

useEffect(() => {
setSections(firstElem(projectInfo));
const fePI = firstElem(projectInfo);
setSections(fePI);
}, [projectInfo]);

const [LoopMode, setLoopMode] = useState(false);
const [loopMode, setLoopMode] = useState(false);

const sortableListClassName = `sortable-${keyWrapper}-list`;
const itemClassName = `sortable-${keyWrapper}-item`;
Expand Down Expand Up @@ -183,7 +186,7 @@ export function WrapperTemplate({
advanceMode={advanceMode}
changePrintData={changePrintData}
setLoopMode={setLoopMode}
loopMode={LoopMode}
loopMode={loopMode}
/>
) : (
<div />
Expand All @@ -194,7 +197,7 @@ export function WrapperTemplate({
advanceMode={advanceMode}
changePrintData={changePrintData}
setLoopMode={setLoopMode}
loopMode={LoopMode}
loopMode={loopMode}
/>
) : (
<div />
Expand All @@ -205,14 +208,14 @@ export function WrapperTemplate({
advanceMode={advanceMode}
changePrintData={changePrintData}
setLoopMode={setLoopMode}
loopMode={LoopMode}
loopMode={loopMode}
/>
) : (
<div />
)}
<div
style={
LoopMode
loopMode
? {
backgroundColor: '#FFEEE5',
}
Expand All @@ -228,7 +231,7 @@ export function WrapperTemplate({
}}
>
<div style={{ display: 'flex' }}>
{advanceMode && (
{advanceMode && showTrashButton && (
<Button
style={{
borderStyle: 'solid',
Expand Down Expand Up @@ -295,7 +298,7 @@ export function WrapperTemplate({
keySpecification={getSectionType(k)}
idjson={k}
removeButton={
advanceMode ? (
advanceMode && Object.keys(JSON.parse(sections)).length > 1 ? (
<Button
onClick={() => {
setOrderSelections(
Expand Down Expand Up @@ -363,7 +366,7 @@ export function WrapperTemplate({
justifyContent: 'space-between',
}}
>
{advanceMode && LoopMode ? (
{advanceMode && loopMode ? (
<Button
style={{
borderRadius: 4,
Expand Down

0 comments on commit b5091ea

Please sign in to comment.