mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Stash rating system (#2830)
* add rating100 fields to represent rating range 1-100 * deprecate existing (1-5) rating fields * add half- and quarter-star options for rating system * add decimal rating system option Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -24,6 +24,15 @@ import {
|
||||
connectionStateLabel,
|
||||
InteractiveContext,
|
||||
} from "src/hooks/Interactive/context";
|
||||
import {
|
||||
defaultRatingStarPrecision,
|
||||
defaultRatingSystemOptions,
|
||||
defaultRatingSystemType,
|
||||
RatingStarPrecision,
|
||||
ratingStarPrecisionIntlMap,
|
||||
ratingSystemIntlMap,
|
||||
RatingSystemType,
|
||||
} from "src/utils/rating";
|
||||
|
||||
const allMenuItems = [
|
||||
{ id: "scenes", headingID: "scenes" },
|
||||
@@ -80,6 +89,24 @@ export const SettingsInterfacePanel: React.FC = () => {
|
||||
});
|
||||
}
|
||||
|
||||
function saveRatingSystemType(t: RatingSystemType) {
|
||||
saveUI({
|
||||
ratingSystemOptions: {
|
||||
...ui.ratingSystemOptions,
|
||||
type: t,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function saveRatingSystemStarPrecision(p: RatingStarPrecision) {
|
||||
saveUI({
|
||||
ratingSystemOptions: {
|
||||
...(ui.ratingSystemOptions ?? defaultRatingSystemOptions),
|
||||
starPrecision: p,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (error) return <h1>{error.message}</h1>;
|
||||
if (loading) return <LoadingIndicator />;
|
||||
|
||||
@@ -415,6 +442,42 @@ export const SettingsInterfacePanel: React.FC = () => {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<SelectSetting
|
||||
id="rating_system"
|
||||
headingID="config.ui.editing.rating_system.type.label"
|
||||
value={ui.ratingSystemOptions?.type ?? defaultRatingSystemType}
|
||||
onChange={(v) => saveRatingSystemType(v as RatingSystemType)}
|
||||
>
|
||||
{Array.from(ratingSystemIntlMap.entries()).map((v) => (
|
||||
<option key={v[0]} value={v[0]}>
|
||||
{intl.formatMessage({
|
||||
id: v[1],
|
||||
})}
|
||||
</option>
|
||||
))}
|
||||
</SelectSetting>
|
||||
{(ui.ratingSystemOptions?.type ?? defaultRatingSystemType) ===
|
||||
RatingSystemType.Stars && (
|
||||
<SelectSetting
|
||||
id="rating_system_star_precision"
|
||||
headingID="config.ui.editing.rating_system.star_precision.label"
|
||||
value={
|
||||
ui.ratingSystemOptions?.starPrecision ??
|
||||
defaultRatingStarPrecision
|
||||
}
|
||||
onChange={(v) =>
|
||||
saveRatingSystemStarPrecision(v as RatingStarPrecision)
|
||||
}
|
||||
>
|
||||
{Array.from(ratingStarPrecisionIntlMap.entries()).map((v) => (
|
||||
<option key={v[0]} value={v[0]}>
|
||||
{intl.formatMessage({
|
||||
id: v[1],
|
||||
})}
|
||||
</option>
|
||||
))}
|
||||
</SelectSetting>
|
||||
)}
|
||||
</SettingSection>
|
||||
|
||||
<SettingSection headingID="config.ui.custom_css.heading">
|
||||
|
||||
Reference in New Issue
Block a user