From 8fab9acd56abc5419e4635fe8fd49e0da2ca51e5 Mon Sep 17 00:00:00 2001 From: Simon Repp Date: Tue, 16 Apr 2024 13:24:21 +0200 Subject: [PATCH] Hide unlisted toggle when editing at the site's root level --- src/editor/endpoints/collection.rs | 7 ++++++- src/editor/endpoints/playlist.rs | 7 ++++++- src/editor/endpoints/video.rs | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/editor/endpoints/collection.rs b/src/editor/endpoints/collection.rs index 85fa521..95172e3 100644 --- a/src/editor/endpoints/collection.rs +++ b/src/editor/endpoints/collection.rs @@ -322,6 +322,11 @@ pub fn edit_page( String::new() }; + let input_unlisted_conditionally_hidden = match collection.path.as_str() { + "" => if collection.unlisted { format!(r#""#)} else { String::new() }, + _ => input_unlisted + }; + let body = formatdoc!(r#" {errors} @@ -331,7 +336,7 @@ pub fn edit_page(
{input_title} {input_description} - {input_unlisted} + {input_unlisted_conditionally_hidden}
{feedback_update} diff --git a/src/editor/endpoints/playlist.rs b/src/editor/endpoints/playlist.rs index 67238c5..fc7c4bf 100644 --- a/src/editor/endpoints/playlist.rs +++ b/src/editor/endpoints/playlist.rs @@ -262,6 +262,11 @@ pub fn edit_page( String::new() }; + let input_unlisted_conditionally_hidden = match playlist.path.as_str() { + "" => if playlist.unlisted { format!(r#""#)} else { String::new() }, + _ => input_unlisted + }; + let body = formatdoc!(r#" {errors} @@ -271,7 +276,7 @@ pub fn edit_page( {input_title} {input_description} - {input_unlisted} + {input_unlisted_conditionally_hidden}
{feedback_update} diff --git a/src/editor/endpoints/video.rs b/src/editor/endpoints/video.rs index bb277e4..6d38615 100644 --- a/src/editor/endpoints/video.rs +++ b/src/editor/endpoints/video.rs @@ -475,6 +475,11 @@ pub fn edit_page( "#); + let input_unlisted_conditionally_hidden = match video.path.as_str() { + "" => if video.unlisted { format!(r#""#)} else { String::new() }, + _ => input_unlisted + }; + let body = formatdoc!(r#" {errors} @@ -485,7 +490,7 @@ pub fn edit_page( {input_title} {input_description} {input_release_date} - {input_unlisted} + {input_unlisted_conditionally_hidden}
{feedback_update}