Add delete button on docs
This commit is contained in:
@@ -8,6 +8,12 @@
|
||||
<div id="notes"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="template-items">
|
||||
<div class="doc-item btn-group" role="group" aria-label="Basic example">
|
||||
<a class="btn btn-outline-primary btn-labeled shadow-sm" href="" target="_blank"><span class="btn-label"><i class="fal file"></i></span><span class="btn-desc"></span></a>
|
||||
<button type="button" class="delete btn btn-danger"><i class="fal fa-delete"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
oCATC.pageInit = function(asHash, bFirstPage) {
|
||||
self.tmp('id_course', asHash.items[0]);
|
||||
@@ -50,10 +56,10 @@ oCATC.pageInit = function(asHash, bFirstPage) {
|
||||
oCATC.feedback('notice', sMsg);
|
||||
});
|
||||
loadDocs();
|
||||
},
|
||||
}/*,
|
||||
progressall: function (e, asData) {
|
||||
$('#progress .bar').css('width', parseInt(asData.loaded / asData.total * 100, 10)+'%');
|
||||
}
|
||||
}*/
|
||||
});
|
||||
loadDocs();
|
||||
};
|
||||
@@ -66,10 +72,22 @@ function loadDocs() {
|
||||
Tools.ajax(
|
||||
'get_docs',
|
||||
(asData) => {
|
||||
var $DocList = $('#doc_list').empty();
|
||||
$.each(asData, function(iKey, asDoc){
|
||||
$('#doc_list').append($('<a>', {'class':'item', href:asDoc.filepath, target:'_blank'})
|
||||
.appendIcon('file-'+asDoc.type)
|
||||
.append(asDoc.filename));
|
||||
var $Item = oCATC.getTemplateItem('doc-item');
|
||||
$Item.find('.btn').addClass(asDoc.type).attr('href', asDoc.filepath);
|
||||
$Item.find('.file').addClass('fa-file-'+asDoc.type);
|
||||
$Item.find('.btn-desc').text(asDoc.filename);
|
||||
$Item.find('.delete').data('id', asDoc.id_doc).click(function(){
|
||||
Tools.ajax(
|
||||
'delete_doc',
|
||||
(asData) => {loadDocs();},
|
||||
{id: $(this).data('id')}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$DocList.append($Item);
|
||||
});
|
||||
|
||||
},
|
||||
@@ -102,7 +120,7 @@ function save(bForce) {
|
||||
}
|
||||
else {
|
||||
var sContent = oEditor.getContent();
|
||||
if(oEditor.id != 0) {
|
||||
if(self.tmp('id_course') != 0) {
|
||||
self.tmp('saving', true);
|
||||
noteFeedback('info', 'Saving...');
|
||||
getInfo(
|
||||
|
||||
Reference in New Issue
Block a user