mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
add link to remove attribute values from all folders, documents
This commit is contained in:
parent
fe6d4d67be
commit
236f3c2e48
|
@ -53,6 +53,7 @@ $(document).ready( function() {
|
|||
<?php
|
||||
$this->printDeleteFolderButtonJs();
|
||||
$this->printDeleteDocumentButtonJs();
|
||||
$this->printDeleteAttributeValueButtonJs();
|
||||
} /* }}} */
|
||||
|
||||
function info() { /* {{{ */
|
||||
|
@ -79,11 +80,12 @@ $(document).ready( function() {
|
|||
$content .= "<th>".getMLText("attribute_count")."</th>\n";
|
||||
$content .= "<th></th>\n";
|
||||
$content .= "</tr></thead>\n<tbody>\n";
|
||||
$separator = $selattrdef->getValueSetSeparator();
|
||||
foreach($res['frequencies'][$type] as $entry) {
|
||||
$value = $selattrdef->parseValue($entry['value']);
|
||||
$content .= "<tr>";
|
||||
$content .= "<td>".implode(';', $value)."</td>";
|
||||
$content .= "<td><a href=\"../out/out.Search.php?resultmode=".($type == 'folder' ? 2 : ($type == 'document' ? 1 : 3))."&attributes[".$selattrdef->getID()."]=".$entry['value']."\">".urlencode($entry['c'])."</a></td>";
|
||||
$content .= "<td>".htmlspecialchars(implode('<span style="color: #aaa;">'.($separator ? ' '.$separator.' ' : ' ; ').'</span>', $value))."</td>";
|
||||
$content .= "<td><a href=\"../out/out.Search.php?resultmode=".($type == 'folder' ? 2 : ($type == 'document' ? 1 : 3))."&attributes[".$selattrdef->getID()."]=".urlencode($entry['value'])."\">".urlencode($entry['c'])."</a></td>";
|
||||
$content .= "<td>";
|
||||
/* various checks, if the value is valid */
|
||||
if(!$selattrdef->validate($entry['value'])) {
|
||||
|
@ -99,6 +101,15 @@ $(document).ready( function() {
|
|||
}
|
||||
*/
|
||||
$content .= "</td>";
|
||||
$content .= "<td>";
|
||||
$content .= "<div class=\"list-action\">";
|
||||
if($user->isAdmin()) {
|
||||
$content .= $this->printDeleteAttributeValueButton($selattrdef, implode(';', $value), 'splash_rm_attr_value', true);
|
||||
} else {
|
||||
$content .= '<span style="padding: 2px; color: #CCC;"><i class="icon-remove"></i></span>';
|
||||
}
|
||||
$content .= "</div>";
|
||||
$content .= "</td>";
|
||||
$content .= "</tr>";
|
||||
}
|
||||
$content .= "</tbody></table>";
|
||||
|
|
|
@ -1842,6 +1842,86 @@ $(document).ready( function() {
|
|||
<?php
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Print button with link for deleting an attribute value
|
||||
*
|
||||
* This button is used in document listings (e.g. on the ViewFolder page)
|
||||
* for deleting a document. In seeddms version < 4.3.9 this was just a
|
||||
* link to the out/out.RemoveDocument.php page which asks for confirmation
|
||||
* an than calls op/op.RemoveDocument.php. Starting with version 4.3.9
|
||||
* the button just opens a small popup asking for confirmation and than
|
||||
* calls the ajax command 'deletedocument'. The ajax call is called
|
||||
* in the click function of 'button.removedocument'. That button needs
|
||||
* to have two attributes: 'rel' for the id of the document, and 'msg'
|
||||
* for the message shown by notify if the document could be deleted.
|
||||
*
|
||||
* @param object $document document to be deleted
|
||||
* @param string $msg message shown in case of successful deletion
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
function printDeleteAttributeValueButton($attrdef, $value, $msg, $return=false){ /* {{{ */
|
||||
$content = '';
|
||||
$content .= '<a class="delete-attribute-value-btn" rel="'.$attrdef->getID().'" msg="'.getMLText($msg).'" attrvalue="'.htmlspecialchars($value, ENT_QUOTES).'" confirmmsg="'.htmlspecialchars(getMLText("confirm_rm_attr_value", array ("attrdefname" => $attrdef->getName())), ENT_QUOTES).'"><i class="icon-remove"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
function printDeleteAttributeValueButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
// $('.delete-attribute-value-btn').click(function(ev) {
|
||||
$('body').on('click', 'a.delete-attribute-value-btn', function(ev){
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
attrvalue = $(ev.currentTarget).attr('attrvalue');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('removeattrvalue')."';
|
||||
bootbox.dialog(confirmmsg, [{
|
||||
\"label\" : \"<i class='icon-remove'></i> ".getMLText("rm_attr_value")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.post('../op/op.AttributeMgr.php',
|
||||
{ action: 'removeattrvalue', attrdefid: id, attrvalue: attrvalue, formtoken: formtoken },
|
||||
function(data) {
|
||||
if(data.success) {
|
||||
$('#table-row-attrvalue-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"class\" : \"btn-cancel\",
|
||||
\"callback\": function() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return HTML of a single row in the document list table
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user