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 @@ class ShaarePublishController extends ShaarliAdminController
$title = $request->getParam('title'); $title = $request->getParam('title');
$description = $request->getParam('description'); $description = $request->getParam('description');
$tags = $request->getParam('tags'); $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 // 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.) // the title (otherwise we will to straight to the edit form.)

View file

@ -654,5 +654,13 @@ function init(description) {
e.preventDefault(); e.preventDefault();
toggleBulkCreationVisibility(bulkCreationButton, bulkCreationForm); 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 @@
</div> </div>
<div> <div>
<input type="checkbox" name="private" <input type="hidden" name="private" value="0">
{if="$default_private_links"} checked="checked"{/if}> <input type="checkbox" name="private" {if="$default_private_links"} checked="checked"{/if}>
&nbsp; <label for="lf_private">{'Private'|t}</label> &nbsp; <label for="lf_private">{'Private'|t}</label>
</div> </div>
</div> </div>

View file

@ -65,7 +65,7 @@
<div> <div>
<input type="checkbox" name="lf_private" id="lf_private" <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" checked="checked"
{/if}> {/if}>
&nbsp;<label for="lf_private">{'Private'|t}</label> &nbsp;<label for="lf_private">{'Private'|t}</label>