Skip to content

Commit

Permalink
added left and right buttons for titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Mond1c committed Apr 22, 2024
1 parent b93d3a2 commit ba80bc9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/backend-api/src/main/kotlin/org/icpclive/api/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ object UnitSettings : ObjectSettings
data class AdvertisementSettings(val text: String) : ObjectSettings

@Serializable
data class TitleSettings(val preset: String, val data: Map<String, String>) : ObjectSettings
data class TitleSettings(
val preset: String,
val leftPreset: String? = null,
val rightPreset: String? = null,
val data: Map<String, String>) : ObjectSettings

@Serializable
data class PictureSettings(val url: String, val name: String) : ObjectSettings
Expand Down
30 changes: 29 additions & 1 deletion src/frontend/admin/src/components/Title.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,37 @@ function TitleTableRow({ data, onShow, onEdit, onDelete }) {
const [editData, onClickEdit, onSubmitEdit, onChangeField] = usePresetTableRowDataState(data, onEdit);
const [previewDialogOpen, setPreviewDialogOpen] = useState(false);

const changePreset = (presetFile) => {
return function() {
const tempData = Object.assign({}, data);
tempData.settings.preset = presetFile;
onEdit(tempData);
};
};

return (<TableRow key={data.id} sx={{ backgroundColor: (data.shown ? activeRowColor : undefined) }}>
<TableCell component="th" scope="row" align={"left"} key="__show_btn_row__">
<ShowPresetButton onClick={onShow} active={data.shown}/>
<Box display="flex">
<ShowPresetButton className='block' onClick={onShow} active={data.shown}/>
<PresetsTableCell
value={data.settings.leftPreset}
editValue={editData?.settings?.preset}
isActive={data.shown}
onChange={onChangeField("leftPreset")}
onSubmit={onSubmitEdit}
valueEditor={TemplateEditor}
/>
<PresetsTableCell
value={data.settings.rightPreset}
editValue={editData?.settings?.preset}
isActive={data.shown}
onChange={onChangeField("rightPreset")}
onSubmit={onSubmitEdit}
valueEditor={TemplateEditor}
/>
<IconButton color="primary" onClick={changePreset(data.settings.leftPreset)}>L</IconButton>
<IconButton color="primary" onClick={changePreset(data.settings.rightPreset)}>R</IconButton>
</Box>
</TableCell>
<PresetsTableCell value={data.settings.preset} editValue={editData?.settings?.preset} isActive={data.shown}
onChange={onChangeField("preset")} onSubmit={onSubmitEdit}
Expand Down

0 comments on commit ba80bc9

Please sign in to comment.