-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
greater flexibility for locked tickets #17099
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: abrantedevops <abrante.devops@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to be rash @oneabrante, but your current PR is unreviewable.
The proposed actual changes (see the relative tab in github UI) are invisible due to a lot of unwanted changes (modifications of copyright header, removal of global comments, moving to majuscules, etc).
Please, restrict the changes to the behavior you want to propose for locks and nothin else.
I'll let you a bit of time to make a better proposition, after a few weeks, we'll close.
And please target |
Signed-off-by: abrantedevops <abrante.devops@gmail.com>
…nto oneabrante-mod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
fix(richtext): text color pasting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed code does not seems to be compatible with the recent refactoring of the feature made in #16538.
|
||
echo "<div class='firstbloc'>"; | ||
echo "<form name='groupuser_form$rand' id='groupuser_form$rand' method='post'"; | ||
echo " action='" . Toolbox::getItemTypeFormURL('User') . "'>"; | ||
|
||
echo "<table class='tab_cadre_fixe'>"; | ||
echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Associate to a group') . "</th></tr>"; | ||
echo "<tr class='tab_bg_2'><td class='center'>"; | ||
echo "<input type='hidden' name='users_id' value='$ID'>"; | ||
|
||
$params = [ | ||
'condition' => [ | ||
'is_usergroup' => 1, | ||
] + getEntitiesRestrictCriteria(Group::getTable(), '', '', true) | ||
]; | ||
|
||
if (count($used) > 0) { | ||
$params['condition'][] = [ | ||
'NOT' => [Group::getTable() . '.id' => $used] | ||
]; | ||
} | ||
|
||
Group::dropdown($params); | ||
echo "</td><td>" . _n('Manager', 'Managers', 1) . "</td><td>"; | ||
Dropdown::showYesNo('is_manager'); | ||
|
||
echo "</td><td>" . __('Delegatee') . "</td><td>"; | ||
Dropdown::showYesNo('is_userdelegate'); | ||
|
||
echo "</td><td class='tab_bg_2 center'>"; | ||
echo "<input type='submit' name='addgroup' value=\"" . _sx('button', 'Add') . "\" | ||
class='btn btn-primary'>"; | ||
|
||
echo "</td></tr>"; | ||
echo "</table>"; | ||
Html::closeForm(); | ||
echo "</div>"; | ||
} | ||
|
||
echo "<div class='spaced'>"; | ||
if ($canedit && count($used)) { | ||
$rand = mt_rand(); | ||
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); | ||
echo "<input type='hidden' name='users_id' value='" . $user->fields['id'] . "'>"; | ||
$massiveactionparams = ['num_displayed' => min($_SESSION['glpilist_limit'], count($used)), | ||
'container' => 'mass' . __CLASS__ . $rand | ||
]; | ||
Html::showMassiveActions($massiveactionparams); | ||
} | ||
echo "<table class='tab_cadre_fixehov'>"; | ||
$header_begin = "<tr>"; | ||
$header_top = ''; | ||
$header_bottom = ''; | ||
$header_end = ''; | ||
|
||
if ($canedit && count($used)) { | ||
$header_begin .= "<th width='10'>"; | ||
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); | ||
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); | ||
$header_end .= "</th>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not seems to be related to the proposed functional change.
@@ -3657,6 +3657,7 @@ public static function initEditorSystem( | |||
branding: false, | |||
selector: '#' + $.escapeSelector('{$id}'), | |||
text_patterns: false, | |||
paste_webkit_styles: 'all', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not seems to be related to the proposed functional change.
private function getScriptToUnlock() | ||
{ | ||
/** @var array $CFG_GLPI */ | ||
global $CFG_GLPI; | ||
|
||
$ret = Html::scriptBlock(" | ||
function unlockIt(obj) { | ||
function callUnlock( ) { | ||
$.post({ | ||
url: '" . $CFG_GLPI['root_doc'] . "/ajax/unlockobject.php', | ||
cache: false, | ||
data: { | ||
unlock: 1, | ||
force: 1, | ||
id: {$this->fields['id']} | ||
}, | ||
dataType: 'json', | ||
success: function( data, textStatus, jqXHR ) { | ||
window.location.reload(true); | ||
}, | ||
error: function() { " . | ||
Html::jsAlertCallback(__('Contact your GLPI admin!'), __('Item NOT unlocked!')) . " | ||
} | ||
}); | ||
}" | ||
. "callUnlock(); | ||
}"); | ||
|
||
return $ret; | ||
} | ||
|
||
/** | ||
* Summary of getForceUnlockMessage | ||
* @return string '' if no rights to unlock type, | ||
* else html @see getForceUnlockButton | ||
*/ | ||
private function getForceUnlockMessage() | ||
{ | ||
|
||
if (isset($_SESSION['glpilocksavedprofile']) && ($_SESSION['glpilocksavedprofile'][strtolower($this->itemtype)] & UNLOCK)) { | ||
echo $this->getScriptToUnlock(); | ||
return $this->getForceUnlockButton(); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
|
||
private function getForceUnlockButton() | ||
{ | ||
$msg = "<a class='btn btn-sm btn-primary ms-2' onclick='javascript:unlockIt(this);'> | ||
<i class='fas fa-unlock'></i> | ||
<span>" . sprintf(__('Force unlock %1s #%2s'), $this->itemtypename, $this->itemid) . "</span> | ||
</a>"; | ||
return $msg; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are not used anymore since #16538.
private function setLockedByYouMessage() | ||
{ | ||
|
||
echo $this->getScriptToUnlock(); | ||
|
||
$msg = "<strong class='nowrap'>"; | ||
$msg .= __("Locked by you!"); | ||
$msg .= $this->getForceUnlockButton(); | ||
$msg .= "</strong>"; | ||
|
||
$this->displayLockMessage($msg); | ||
} | ||
|
||
|
||
/** | ||
* Summary of setLockedByMessage | ||
* Shows 'Locked by ' message and proposes to request unlock from locker | ||
**/ | ||
private function setLockedByMessage() | ||
{ | ||
/** @var array $CFG_GLPI */ | ||
global $CFG_GLPI; | ||
|
||
// should get locking user info | ||
$user = new User(); | ||
$user->getFromDB($this->fields['users_id']); | ||
|
||
$useremail = new UserEmail(); | ||
$showAskUnlock = $useremail->getFromDBByCrit([ | ||
'users_id' => $this->fields['users_id'], | ||
'is_default' => 1 | ||
]) && ($CFG_GLPI['notifications_mailing'] == 1); | ||
|
||
$userdata = getUserName($this->fields['users_id'], 2); | ||
|
||
if ($showAskUnlock) { | ||
$ret = Html::scriptBlock(" | ||
function askUnlock() { | ||
" . Html::jsConfirmCallback(__('Ask for unlock this item?'), $this->itemtypename . " #" . $this->itemid, "function() { | ||
$.post({ | ||
url: '" . $CFG_GLPI['root_doc'] . "/ajax/unlockobject.php', | ||
cache: false, | ||
data: { | ||
requestunlock: 1, | ||
id: {$this->fields['id']} | ||
}, | ||
dataType: 'json', | ||
success: function( data, textStatus, jqXHR ) { | ||
" . Html::jsAlertCallback($userdata['name'], __('Request sent to')) . " | ||
} | ||
}); | ||
}") . " | ||
}"); | ||
echo $ret; | ||
} | ||
|
||
$ret = Html::scriptBlock(" | ||
$(function(){ | ||
var lockStatusTimer; | ||
$('#alertMe').on('change',function( eventObject ){ | ||
if( this.checked ) { | ||
lockStatusTimer = setInterval( function() { | ||
$.get({ | ||
url: '" . $CFG_GLPI['root_doc'] . "/ajax/unlockobject.php', | ||
cache: false, | ||
data: 'lockstatus=1&id=" . $this->fields['id'] . "', | ||
success: function( data, textStatus, jqXHR ) { | ||
if( data == 0 ) { | ||
clearInterval(lockStatusTimer);" . | ||
Html::jsConfirmCallback(__('Reload page?'), __('Item unlocked!'), "function() { | ||
window.location.reload(true); | ||
}") . " | ||
} | ||
} | ||
}); | ||
},15000) | ||
} else { | ||
clearInterval(lockStatusTimer); | ||
} | ||
}); | ||
}); | ||
"); | ||
|
||
$msg = "<strong class='nowrap'>"; | ||
$msg .= sprintf(__('Locked by %s'), "<a href='" . $user->getLinkURL() . "'>" . $userdata['name'] . "</a>"); | ||
$msg .= " " . Html::showToolTip($userdata["comment"], ['link' => $userdata['link'], 'display' => false]); | ||
$msg .= " -> " . Html::convDateTime($this->fields['date']); | ||
$msg .= "</strong>"; | ||
if ($showAskUnlock) { | ||
$msg .= "<a class='btn btn-sm btn-primary ms-2' onclick='javascript:askUnlock();'> | ||
<i class='fas fa-unlock'></i> | ||
<span>" . __('Ask for unlock') . "</span> | ||
</a>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #16538, most of the front code has been moved in a dedicated JS files and a dedicated Twig template.
The current dynamics of blocking tickets becomes somewhat "bureaucratic", laborious and tiring for whoever is managing/forwarding the tickets, whether to another group, technician or being in charge. I am currently experiencing a scenario in which the current ticket blocking configuration has become a separate challenge in terms of bringing more ease and speed to blocked tickets.
Fixed configuration:
The scenario was this:
When the technician requested writing in the ticket, the standard editing options were enabled, as shown in the image below.
In this case, if for example a page was reloaded, or if a specific group was assigned, as well as the technician himself being in charge of the ticket, the blocking model was provided and thus the editing of the ticket with the standard update fields were no longer enabled.
Other than that, to unblock tickets, 2 modes are called requesting confirmation from the technician and to reload the page. I believe that this situation, when we have a lot of assistance throughout the day, where we have a predicted pattern based on ticket blocking, becomes an arduous task.
With this in mind, I implemented a suggestion to bring greater flexibility to allow editing of the ticket by the author of the block, as well as the removal of both modes when unlocking the ticket.