Skip to content

Commit

Permalink
Merge pull request #53 from beatrycze-volk/fix-dialog
Browse files Browse the repository at this point in the history
[BUGFIX] Fix `Dialog` in `ExtendController`
  • Loading branch information
beatrycze-volk authored Jan 24, 2025
2 parents fc92fff + 0f45fb8 commit c175c16
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 55 deletions.
8 changes: 3 additions & 5 deletions Classes/Controller/ExtendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,18 @@ public function dialogAction()
// check if fe_user exists OR cookie for private usage is set
// return empty string
if ($user || $GLOBALS["TSFE"]->fe_user->getKey("ses", $this->settings['dialog']['cookieName'])) {
$this->view->assign('hideDialog', true);
return;
}

//get request arguments
$arguments = $this->request->getArguments();

//check if cookie for private usage should be set --> redirect
if (isset($arguments['setCookie'])) {
//set cookie for private user
$GLOBALS["TSFE"]->fe_user->setKey("ses", $this->settings['dialog']['cookieName'], true);
try {
$this->redirectToKitodoView(['tx_dlf' => $kitodoParams]);
} catch (StopActionException $e) {
}
$this->redirectToKitodoView(['tx_dlf' => $kitodoParams]);
}

//add assets
Expand Down
103 changes: 53 additions & 50 deletions Resources/Private/Extensions/femanager/Templates/Extend/Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,68 @@
data-namespace-typo3-fluid="true"
lang="en">

<div class="content-wrapper container digas-fe-management--dialog">
<f:if condition="{hideDialog}">
<f:else>
<div class="content-wrapper container digas-fe-management--dialog">

<h2><f:translate key="dialog.title" /></h2>
<p>
<f:translate key="dialog.question" />
</p>
<h2><f:translate key="dialog.title" /></h2>
<p>
<f:translate key="dialog.question" />
</p>

<div class="femanager_fieldset femanager_gender form-group">
<div class="radio">
<label for="user_commercial">
<input type="radio" id="user_commercial" name="user_type" {f:if(condition:'{checkYes}',then:'checked="checked"')} value="1"/>
<f:translate key="dialog.yes" />
</label>
</div>
<div class="radio">
<label for="user_private">
<input type="radio" id="user_private" name="user_type" value="1" />
<f:translate key="dialog.no" />
</label>
</div>
</div>
<div class="femanager_fieldset femanager_gender form-group">
<div class="radio">
<label for="user_commercial">
<input type="radio" id="user_commercial" name="user_type" {f:if(condition:'{checkYes}',then:'checked="checked"')} value="1"/>
<f:translate key="dialog.yes" />
</label>
</div>
<div class="radio">
<label for="user_private">
<input type="radio" id="user_private" name="user_type" value="1" />
<f:translate key="dialog.no" />
</label>
</div>
</div>


<div id="user_private_form" class="digas-fe-management--hidden">
<f:form class="form-horizontal"
action="dialog"
arguments="{setCookie:1}"
additionalParams="{tx_dlf:{id:'{kitodoParams.id}',page:'{kitodoParams.page}'}}">
<input type="submit" class="btn btn-primary btn-large" value="{f:translate(key:'dialog.continue')}" />
</f:form>
</div>
<div id="user_private_form" class="digas-fe-management--hidden">
<f:form class="form-horizontal"
action="dialog"
arguments="{setCookie:1}"
additionalParams="{tx_dlf:{id:'{kitodoParams.id}',page:'{kitodoParams.page}'}}">
<input type="submit" class="btn btn-primary btn-large" value="{f:translate(key:'dialog.continue')}" />
</f:form>
</div>


<div id="user_commercial_form" class="{f:if(condition:'!{checkYes}',then:'digas-fe-management--hidden')}">
<f:cObject typoscriptObjectPath="lib.kitodoTempUserForm" />
</div>
<div id="user_commercial_form" class="{f:if(condition:'!{checkYes}',then:'digas-fe-management--hidden')}">
<f:cObject typoscriptObjectPath="lib.kitodoTempUserForm" />
</div>


<p>
<em><f:translate key="dialog.hint" /></em>
</p>
<p>
<em><f:translate key="dialog.hint" /></em>
</p>


<script type="text/javascript">
var digasFeManagementExtendDialog = function (radio) {
var hide = radio.target.id === 'user_private' ? 'user_commercial_form' : 'user_private_form';

if (document.getElementById(radio.target.id).checked === true) {
document.getElementById(radio.target.id + '_form').style.display='block';
document.getElementById(hide).style.display='none';
}
else {
document.getElementById('user_private_form').style.display='none';
document.getElementById('user_commercial_form').style.display='none';
}
};
document.getElementById('user_private').addEventListener('click', digasFeManagementExtendDialog);
document.getElementById('user_commercial').addEventListener('click', digasFeManagementExtendDialog);
</script>
</div>
<script type="text/javascript">
var digasFeManagementExtendDialog = function (radio) {
var hide = radio.target.id === 'user_private' ? 'user_commercial_form' : 'user_private_form';

if (document.getElementById(radio.target.id).checked === true) {
document.getElementById(radio.target.id + '_form').style.display='block';
document.getElementById(hide).style.display='none';
}
else {
document.getElementById('user_private_form').style.display='none';
document.getElementById('user_commercial_form').style.display='none';
}
};
document.getElementById('user_private').addEventListener('click', digasFeManagementExtendDialog);
document.getElementById('user_commercial').addEventListener('click', digasFeManagementExtendDialog);
</script>
</div>
</f:else>
</f:if>
</html>

0 comments on commit c175c16

Please sign in to comment.