mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Restore movie/studio data on edit cancel (#476)
This commit is contained in:
@@ -165,6 +165,11 @@ export const Movie: React.FC = () => {
|
|||||||
ImageUtils.onImageChange(event, onBackImageLoad);
|
ImageUtils.onImageChange(event, onBackImageLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onToggleEdit() {
|
||||||
|
setIsEditing(!isEditing);
|
||||||
|
updateMovieData(movie);
|
||||||
|
}
|
||||||
|
|
||||||
function renderDeleteAlert() {
|
function renderDeleteAlert() {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -266,7 +271,7 @@ export const Movie: React.FC = () => {
|
|||||||
objectName={name ?? "movie"}
|
objectName={name ?? "movie"}
|
||||||
isNew={isNew}
|
isNew={isNew}
|
||||||
isEditing={isEditing}
|
isEditing={isEditing}
|
||||||
onToggleEdit={() => setIsEditing(!isEditing)}
|
onToggleEdit={onToggleEdit}
|
||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
onImageChange={onImageChange}
|
onImageChange={onImageChange}
|
||||||
onBackImageChange={onBackImageChange}
|
onBackImageChange={onBackImageChange}
|
||||||
|
|||||||
@@ -41,5 +41,8 @@ export const MovieScenesPanel: React.FC<IMovieScenesPanel> = ({ movie }) => {
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <SceneList subComponent filterHook={filterHook} />;
|
if (movie && movie.id) {
|
||||||
|
return <SceneList subComponent filterHook={filterHook} />;
|
||||||
|
}
|
||||||
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -150,6 +150,11 @@ export const Studio: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onToggleEdit() {
|
||||||
|
setIsEditing(!isEditing);
|
||||||
|
updateStudioData(studio);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div
|
<div
|
||||||
@@ -180,7 +185,7 @@ export const Studio: React.FC = () => {
|
|||||||
objectName={name ?? "studio"}
|
objectName={name ?? "studio"}
|
||||||
isNew={isNew}
|
isNew={isNew}
|
||||||
isEditing={isEditing}
|
isEditing={isEditing}
|
||||||
onToggleEdit={() => setIsEditing(!isEditing)}
|
onToggleEdit={onToggleEdit}
|
||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
onImageChange={onImageChangeHandler}
|
onImageChange={onImageChangeHandler}
|
||||||
onAutoTag={onAutoTag}
|
onAutoTag={onAutoTag}
|
||||||
|
|||||||
@@ -63,20 +63,20 @@ const renderInputGroup = (options: {
|
|||||||
{options.value}
|
{options.value}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<Form.Control
|
|
||||||
className="text-input"
|
|
||||||
readOnly={!options.isEditing}
|
|
||||||
plaintext={!options.isEditing}
|
|
||||||
value={options.value}
|
|
||||||
placeholder={options.placeholder ?? options.title}
|
|
||||||
onChange={(event: React.FormEvent<HTMLInputElement>) =>
|
|
||||||
options.onChange(event.currentTarget.value)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form.Control
|
||||||
|
className="text-input"
|
||||||
|
readOnly={!options.isEditing}
|
||||||
|
plaintext={!options.isEditing}
|
||||||
|
value={options.value ?? ""}
|
||||||
|
placeholder={options.placeholder ?? options.title}
|
||||||
|
onChange={(event: React.FormEvent<HTMLInputElement>) =>
|
||||||
|
options.onChange(event.currentTarget.value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderDurationInput = (options: {
|
const renderDurationInput = (options: {
|
||||||
@@ -86,7 +86,7 @@ const renderDurationInput = (options: {
|
|||||||
asString?: boolean
|
asString?: boolean
|
||||||
onChange: (value: string | undefined) => void;
|
onChange: (value: string | undefined) => void;
|
||||||
}) => {
|
}) => {
|
||||||
let numericValue: number | undefined = undefined;
|
let numericValue: number | undefined;
|
||||||
if (options.value) {
|
if (options.value) {
|
||||||
if (!options.asString) {
|
if (!options.asString) {
|
||||||
try {
|
try {
|
||||||
@@ -100,7 +100,7 @@ const renderDurationInput = (options: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!options.isEditing) {
|
if (!options.isEditing) {
|
||||||
let durationString = undefined;
|
let durationString;
|
||||||
if (numericValue !== undefined) {
|
if (numericValue !== undefined) {
|
||||||
durationString = DurationUtils.secondsToString(numericValue);
|
durationString = DurationUtils.secondsToString(numericValue);
|
||||||
}
|
}
|
||||||
@@ -108,26 +108,26 @@ const renderDurationInput = (options: {
|
|||||||
return (
|
return (
|
||||||
<Form.Control
|
<Form.Control
|
||||||
className="text-input"
|
className="text-input"
|
||||||
readOnly={true}
|
readOnly
|
||||||
plaintext={true}
|
plaintext
|
||||||
defaultValue={durationString}
|
defaultValue={durationString}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<DurationInput
|
|
||||||
disabled={!options.isEditing}
|
|
||||||
numericValue={numericValue}
|
|
||||||
onValueChange={(valueAsNumber: number, valueAsString? : string) => {
|
|
||||||
if (!options.asString) {
|
|
||||||
valueAsString = valueAsNumber !== undefined ? valueAsNumber.toString() : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
options.onChange(valueAsString);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return (
|
||||||
|
<DurationInput
|
||||||
|
disabled={!options.isEditing}
|
||||||
|
numericValue={numericValue}
|
||||||
|
onValueChange={(valueAsNumber: number, valueAsString? : string) => {
|
||||||
|
let value = valueAsString;
|
||||||
|
if (!options.asString) {
|
||||||
|
value = valueAsNumber !== undefined ? valueAsNumber.toString() : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
options.onChange(value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderHtmlSelect = (options: {
|
const renderHtmlSelect = (options: {
|
||||||
@@ -140,31 +140,30 @@ const renderHtmlSelect = (options: {
|
|||||||
return (
|
return (
|
||||||
<Form.Control
|
<Form.Control
|
||||||
className="text-input"
|
className="text-input"
|
||||||
readOnly={true}
|
readOnly
|
||||||
plaintext={true}
|
plaintext
|
||||||
defaultValue={options.value}
|
defaultValue={options.value}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<Form.Control
|
|
||||||
as="select"
|
|
||||||
className="input-control"
|
|
||||||
disabled={!options.isEditing}
|
|
||||||
plaintext={!options.isEditing}
|
|
||||||
value={options.value?.toString()}
|
|
||||||
onChange={(event: React.FormEvent<HTMLSelectElement>) =>
|
|
||||||
options.onChange(event.currentTarget.value)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{options.selectOptions.map((opt) => (
|
|
||||||
<option value={opt} key={opt}>
|
|
||||||
{opt}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</Form.Control>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return (
|
||||||
|
<Form.Control
|
||||||
|
as="select"
|
||||||
|
className="input-control"
|
||||||
|
disabled={!options.isEditing}
|
||||||
|
plaintext={!options.isEditing}
|
||||||
|
value={options.value?.toString()}
|
||||||
|
onChange={(event: React.FormEvent<HTMLSelectElement>) =>
|
||||||
|
options.onChange(event.currentTarget.value)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{options.selectOptions.map((opt) => (
|
||||||
|
<option value={opt} key={opt}>
|
||||||
|
{opt}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Form.Control>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: isediting
|
// TODO: isediting
|
||||||
|
|||||||
Reference in New Issue
Block a user