Bulk creation: fix private status based on the first form

This commit is contained in:
ArthurHoaro 2020-10-11 13:34:38 +02:00
parent 5d8de7587d
commit 25e90d8d75
4 changed files with 16 additions and 4 deletions

View file

@ -169,7 +169,11 @@ protected function buildLinkDataFromUrl(Request $request, string $url): array
$title = $request->getParam('title');
$description = $request->getParam('description');
$tags = $request->getParam('tags');
$private = filter_var($request->getParam('private'), FILTER_VALIDATE_BOOLEAN);
if ($request->getParam('private') !== null) {
$private = filter_var($request->getParam('private'), FILTER_VALIDATE_BOOLEAN);
} else {
$private = $this->container->conf->get('privacy.default_private_links', false);
}
// If this is an HTTP(S) link, we try go get the page to extract
// the title (otherwise we will to straight to the edit form.)

View file

@ -654,5 +654,13 @@ function init(description) {
e.preventDefault();
toggleBulkCreationVisibility(bulkCreationButton, bulkCreationForm);
});
// Force to send falsy value if the checkbox is not checked.
const privateButton = bulkCreationForm.querySelector('input[type="checkbox"][name="private"]');
const privateHiddenButton = bulkCreationForm.querySelector('input[type="hidden"][name="private"]');
privateButton.addEventListener('click', () => {
privateHiddenButton.disabled = !privateHiddenButton.disabled;
});
privateHiddenButton.disabled = privateButton.checked;
}
})();

View file

@ -62,8 +62,8 @@ <h2 class="window-title">{"Shaare multiple new links"|t}</h2>
</div>
<div>
<input type="checkbox" name="private"
{if="$default_private_links"} checked="checked"{/if}>
<input type="hidden" name="private" value="0">
<input type="checkbox" name="private" {if="$default_private_links"} checked="checked"{/if}>
&nbsp; <label for="lf_private">{'Private'|t}</label>
</div>
</div>

View file

@ -65,7 +65,7 @@ <h2 class="window-title">
<div>
<input type="checkbox" name="lf_private" id="lf_private"
{if="($link_is_new && $default_private_links || $link.private == true)"}
{if="$link.private === true"}
checked="checked"
{/if}>
&nbsp;<label for="lf_private">{'Private'|t}</label>