Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Comptoir
Comptoir-srv
Commits
19f99baf
Commit
19f99baf
authored
Jun 08, 2020
by
Fabrice Gangler
🎨
Browse files
FIX(actionHelper): update for add software button
parent
d12c3e83
Pipeline
#9941
passed with stage
in 3 minutes and 35 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/View/Helper/ActionHelper.php
View file @
19f99baf
...
...
@@ -28,25 +28,27 @@ class ActionHelper extends Helper
/**
* Create form with one button
*
* @param string $formMethod
* @param string $controller
* @param string $action
* @param int $id
* @param string $btnText
* @param string $btnClass
* @param string $formUrl
* @param string $btnExtraClass
* @param $formMethod
* @param $controller
* @param $action
* @param $id
* @param $btnTxt
* @param $btnClass
* @param $formUrl
* @param string $btnExtraClass default = ''
* @param bool $bypassCheckId default = false
* @return string|null
*/
private
function
communB
utto
n
(
private
function
communB
t
n
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnT
e
xt
,
$btnTxt
,
$btnClass
,
$formUrl
,
$btnExtraClass
=
''
$btnExtraClass
=
''
,
$bypassCheckId
=
false
)
{
$userType
=
$this
->
request
->
session
()
->
read
(
'Auth.User.user_type'
);
if
(
$userType
===
null
)
{
...
...
@@ -54,7 +56,8 @@ class ActionHelper extends Helper
}
$htmlId
=
"
$controller
-
$action
-
$id
"
;
if
(
!
is_null
(
$id
)
&&
$this
->
hasAccess
(
$userType
,
$controller
,
$action
))
{
$hasAccess
=
$this
->
hasAccess
(
$userType
,
$controller
,
$action
);
if
((
!
is_null
(
$id
)
||
$bypassCheckId
)
&&
$hasAccess
)
{
$btnCssClass
=
$btnClass
.
' '
.
$btnExtraClass
;
$formOptions
=
[
"url"
=>
$formUrl
,
...
...
@@ -64,7 +67,7 @@ class ActionHelper extends Helper
];
$html
=
''
;
$html
.
=
$this
->
Form
->
create
(
null
,
$formOptions
);
$html
.
=
$this
->
Form
->
button
(
$btnT
e
xt
,
[
"class"
=>
$btnCssClass
,
"id"
=>
"btn_
$htmlId
"
,]);
$html
.
=
$this
->
Form
->
button
(
$btnTxt
,
[
"class"
=>
$btnCssClass
,
"id"
=>
"btn_
$htmlId
"
,]);
$html
.
=
$this
->
Form
->
end
();
return
$html
;
}
else
{
...
...
@@ -81,7 +84,7 @@ class ActionHelper extends Helper
*/
public
function
edit
(
array
$options
)
{
$btnT
e
xt
=
isset
(
$options
[
"text"
])
?
$options
[
"text"
]
:
"Edit"
;
$btnTxt
=
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"
]
:
$this
->
request
->
controller
;
...
...
@@ -92,7 +95,7 @@ class ActionHelper extends Helper
}
else
{
$formUrl
=
[
'prefix'
=>
false
,
'controller'
=>
$controller
,
'action'
=>
$action
,
$id
];
}
return
$this
->
communB
utto
n
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnT
e
xt
,
$btnClass
,
$formUrl
);
return
$this
->
communB
t
n
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnTxt
,
$btnClass
,
$formUrl
);
}
/**
...
...
@@ -101,7 +104,7 @@ class ActionHelper extends Helper
*/
public
function
fallBack
(
array
$options
)
{
$btnT
e
xt
=
isset
(
$options
[
"text"
])
?
$options
[
"text"
]
:
"Delete"
;
$btnTxt
=
isset
(
$options
[
"text"
])
?
$options
[
"text"
]
:
"Delete"
;
$btnClass
=
isset
(
$options
[
"class"
])
?
$options
[
'class'
]
:
"btn btn-default removeOne"
;
$formMethod
=
isset
(
$options
[
"method"
])
?
$options
[
"method"
]
:
"delete"
;
// default post method
$controller
=
isset
(
$options
[
"controller"
])
?
$options
[
"controller"
]
:
$this
->
request
->
controller
;
...
...
@@ -112,7 +115,7 @@ class ActionHelper extends Helper
}
else
{
$formUrl
=
[
'prefix'
=>
false
,
'controller'
=>
$controller
,
'action'
=>
$action
,
$id
];
}
return
$this
->
communB
utto
n
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnT
e
xt
,
$btnClass
,
$formUrl
);
return
$this
->
communB
t
n
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnTxt
,
$btnClass
,
$formUrl
);
}
/**
...
...
@@ -122,24 +125,29 @@ class ActionHelper extends Helper
*/
public
function
participate
(
array
$options
)
{
$btnT
e
xt
=
isset
(
$options
[
"text"
])
?
$options
[
"text"
]
:
null
;
$btnTxt
=
isset
(
$options
[
"text"
])
?
$options
[
"text"
]
:
null
;
$btnClass
=
isset
(
$options
[
"class"
])
?
$options
[
'class'
]
:
"btn btn-default addmore"
;
$btnExtraClass
=
isset
(
$options
[
"extraCssClass"
])
?
$options
[
"extraCssClass"
]
:
""
;
$formMethod
=
isset
(
$options
[
"method"
])
?
$options
[
"method"
]
:
"post"
;
// default post method
$c
ontroller
=
isset
(
$options
[
"controller"
])
?
$options
[
"controller"
]
:
$this
->
request
->
controller
;
$c
trl
=
isset
(
$options
[
"controller"
])
?
$options
[
"controller"
]
:
$this
->
request
->
controller
;
$action
=
isset
(
$options
[
"action"
])
?
$options
[
"action"
]
:
"add"
;
$id
=
isset
(
$options
[
"id"
])
?
$options
[
"id"
]
:
null
;
if
(
isset
(
$options
[
"url"
]))
{
$formUrl
=
$options
[
"url"
];
}
else
{
$formUrl
=
[
'prefix'
=>
false
,
'controller'
=>
$c
ontroller
,
'action'
=>
$action
,
$id
];
$formUrl
=
[
'prefix'
=>
false
,
'controller'
=>
$c
trl
,
'action'
=>
$action
,
$id
];
}
$html
=
$this
->
communButton
(
$formMethod
,
$controller
,
$action
,
$id
,
$btnText
,
$btnClass
,
$formUrl
);
if
(
is_null
(
$html
)
&&
!
is_null
(
$btnText
))
{
$htmlId
=
"
$controller
-
$action
-
$id
"
;
$bypassTestId
=
false
;
if
(
$ctrl
===
'Softwares'
&&
$action
===
'add'
)
{
// prevent test on ID (null equals) performed into communBtn() for this case
$bypassTestId
=
true
;
}
$html
=
$this
->
communBtn
(
$formMethod
,
$ctrl
,
$action
,
$id
,
$btnTxt
,
$btnClass
,
$formUrl
,
''
,
$bypassTestId
);
if
(
is_null
(
$html
)
&&
!
is_null
(
$btnTxt
))
{
$htmlId
=
"
$ctrl
-
$action
-
$id
"
;
$html
=
$this
->
Form
->
button
(
$btnT
e
xt
,
$btnTxt
,
[
"class"
=>
"btn btn-default inactive-button "
.
$btnExtraClass
,
"disabled"
=>
"disabled"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment