Commit 0ecfad95 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

FEAT(mapping)!: adding edit button

BREAKING CHANGE: your config/comptoir.php file must be updated

Refs: #903
parent 9c018684
......@@ -47,6 +47,15 @@ return [
],
// Some kind of ACL for views
'ACL' => [
'TaxonomysSoftwares' => [
'mappingForm' => [
'Administration' => true,
'Association' => false,
'Person' => false,
'Company' => false,
'Unknown' => true,
],
],
'Users' => [
'add' => [
'Administration' => false,
......
......@@ -138,6 +138,10 @@ msgstr ""
msgid "Softwares.Users.DelcareAs.user.removeMessage"
msgstr ""
#: Template/Api/V1/Softwares/view.ctp:34
msgid "Softwares.Users.DelcareAs.updateTaxonomy"
msgstr ""
#: Template/Api/V1/Softwares/users_software.ctp:32
msgid "Roll back from users' list of {0}."
msgstr ""
......
......@@ -139,6 +139,10 @@ msgstr "Declare yourself as user"
msgid "Softwares.Users.DelcareAs.user.removeMessage"
msgstr "No longer being a"
#: Template/Api/V1/Softwares/view.ctp:34
msgid "Softwares.Users.DelcareAs.updateTaxonomy"
msgstr "Update your statement"
#: Template/Api/V1/Softwares/users_software.ctp:32
msgid "Roll back from users' list of {0}."
msgstr ""
......
......@@ -137,6 +137,10 @@ msgstr "Se déclarer utilisateur"
msgid "Softwares.Users.DelcareAs.user.removeMessage"
msgstr "Ne plus être utilisateur"
#: Template/Api/V1/Softwares/view.ctp:34
msgid "Softwares.Users.DelcareAs.updateTaxonomy"
msgstr "Modifier votre déclaration"
#: Template/Api/V1/Softwares/users_software.ctp:32
msgid "Roll back from users' list of {0}."
msgstr ""
......
......@@ -33,6 +33,13 @@ $this->assign('title', __d("Softwares", "{0}", $software->softwarename));
"action" => "deleteUsersSoftware",
"text" => __d("Softwares", "Softwares.Users.DelcareAs.user.removeMessage", $software->softwarename),
],
"linkEdit" => [
"id" => $software->id,
"controller" => "TaxonomysSoftwares",
"action" => "mappingForm",
"url" => "/$selectedLanguage/mappingForm/". $software->id,
"text" => __d("Softwares", "Softwares.Users.DelcareAs.updateTaxonomy"),
],
"indicator" => [
"idTooltip" => "usersOfListId",
"indicatorMessage" => __d("Softwares", "softwares.usersOfList", $software->softwarename)
......
......@@ -19,6 +19,50 @@ class ActionHelper extends Helper
public $helpers = ['Html', 'Text', 'Time', 'Form'];
/**
* Edit button
*
* @param array $options
* @return string|null
*/
public function edit(array $options)
{
$btnText = isset($options["text"]) ? $options["text"] : "Edit";
$btnClass = isset($options["class"]) ? $options['class'] : "btn btn-default addmore btn-edit";
$formMethod = isset($options["method"]) ? $options["method"] : "post"; // default post method
$controller = isset($options["controller"]) ? $options["controller"] : null;
$action = isset($options["action"]) ? $options["action"] : 'edit';
$id = isset($options["id"]) ? $options["id"] : null;
if (isset($options["url"])) {
$formUrl = $options["url"];
} else {
$formUrl = ['prefix' => false, 'controller' => $controller, 'action' => $action, $id];
}
$htmlId = "$controller-$action-$id";
$hasAccess = $this->hasAccess(
$this->request->session()->read('Auth.User.user_type'),
$controller,
$action
);
if (!is_null($controller) && $hasAccess) {
$formOptions = [
"url" => $formUrl,
"class" => "addmore-form",
"type" => $formMethod,
"id" => "Form_$htmlId",
];
$html = '';
$html .= $this->Form->create(null, $formOptions);
$html .= $this->Form->button($btnText, ["class" => $btnClass, "id" => "btn_$htmlId",]);
$html .= $this->Form->end();
return $html;
} else {
return null;
}
}
/**
* fallback
* @param array $options
......@@ -50,7 +94,6 @@ class ActionHelper extends Helper
],
"class" => "addmore-form",
"type" => $options['method'],
$options["id"]
]
) .
$this->Form->button($options["text"], ["class" => $options["class"]]) .
......@@ -99,7 +142,6 @@ class ActionHelper extends Helper
],
"class" => "addmore-form",
"type" => $options["method"], // default post method
$options["id"]
]
) . $this->Form->button($options["text"], ["class" => $options["class"] . ' ' . $options["extraCssClass"]])
. $this->Form->end();
......
......@@ -58,13 +58,31 @@ class ListsHelper extends Helper
$itemsDisplay = $this->items($items, $options, $limit);
$seeAll = $this->linkSeeMore(count($items), $options);
}
$participateLink = ($this->userIsInList(
$items,
$options
) && $this->request->session()->read('Auth.User.user_type') !== null) ?
$this->Action->fallBack(isset($options["linkFallBack"]) ? $options["linkFallBack"] : []) :
$this->Action->participate(isset($options['linkParticipate']) ? $options['linkParticipate'] : []);
if (!isset($options["linkFallBack"])) {
$options["linkFallBack"] = [];
}
if (!isset($options['linkParticipate'])) {
$options['linkParticipate'] = [];
}
if (!isset($options['linkEdit'])) {
$options['linkEdit'] = [];
}
$participateLink = '';
if ($this->userIsInList($items, $options)
&& $this->request->session()->read('Auth.User.user_type') !== null
) {
$participateLink .= $this->Action->fallBack($options['linkFallBack']);
$participateLink .= $this->Action->edit($options['linkEdit']);
} else {
$participateLink .= $this->Action->participate($options['linkParticipate']);
}
if (!empty($participateLink)) {
$participateLink = "<div class=\"container_btn-participate\">$participateLink </div>
<div class=\"clearFloat\"></div>";
}
$header = $this->formatTemplate(
'header',
[
......
......@@ -755,12 +755,26 @@ section p {
.addmore:hover {
margin-top: 2em;
float: right;
border: 2px solid #D9D9DE;
border: 2px solid #103e10;
font-size: 15px;
color: #FFFFFF;
text-decoration: #fff;
background-color: #2A874B;
box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.18);
box-shadow: 12px 12px 17px rgba(0, 0, 0, 0.18);
}
.btn-edit, .btn-edit:hover {
margin-top: 2.5em;
margin-right: 2em;
}
.container_btn-participate {
float: right;
height: auto;
}
.clearFloat {
clear: both;
height: 0; overflow: hidden; /* Précaution pour IE 7 */
}
.edit-software,
......@@ -777,6 +791,10 @@ section p {
box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.18);
}
.edit-software:hover {
border: 2px solid #103e10;
}
.contact-user,
.contact-user:hover {
position: absolute;
......@@ -803,7 +821,7 @@ section p {
.removeOne:hover {
margin-top: 2.5em;
float: right;
border: 2px solid #D9D9DE;
border: 2px solid #8b0719;
font-size: 15px;
color: #0E0E0E;
text-decoration: #fff;
......@@ -1272,12 +1290,14 @@ img.img-placeholder {
.filter {
background-color: #0069B4;
color: #F5F5F5;
border: 1px solid #0069B4;
}
.search:hover,
.filter:hover {
background-color: #0069B4;
color: #F5F5F5;
border: 1px solid black;
}
.filter {
......@@ -1609,3 +1629,7 @@ https://stackoverflow.com/questions/306924/can-i-change-the-checkbox-size-using-
box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.18);
width: 20em;
}
#taxonomyFormButton:hover {
border: 2px solid #103e10;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment