Finished the bulk get snippets UI area. Tweaked some of the get snipptes scripts, added some icons gh-92

This commit is contained in:
2017-11-18 02:04:14 +02:00
parent dece9016ba
commit eb43f1e3bc
7 changed files with 230 additions and 43 deletions

View File

@ -104,7 +104,6 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
// Set the default uikit components in this view.
$uikitComp = array();
$uikitComp[] = 'UIkit.notify';
$uikitComp[] = 'data-uk-tooltip';
$uikitComp[] = 'data-uk-grid';
}
@ -190,6 +189,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
$this->document->addScriptDeclaration("var lang_Snippet = '".JText::_('COM_COMPONENTBUILDER_SNIPPET')."';");
$this->document->addScriptDeclaration("var lang_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippet = '".JText::_('COM_COMPONENTBUILDER_GET_SNIPPET')."';");
$this->document->addScriptDeclaration("var lang_Dont_Get_Snippet = '".JText::_('COM_COMPONENTBUILDER_LOCAL_SNIPPET')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippet_New_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippet_Dont_Tooltip = '".JText::_('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION')."';");
@ -208,6 +208,11 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
$this->document->addScriptDeclaration("var lang_Author_Name = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_NAME')."';");
$this->document->addScriptDeclaration("var lang_Author_Email = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_EMAIL')."';");
$this->document->addScriptDeclaration("var lang_Author_Website = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_WEBSITE')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippets_New_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippets_Diverged_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippets_Ahead_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippets_Behind_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME')."';");
$this->document->addScriptDeclaration("var lang_Get_Snippets_All_Tooltip = '".JText::_('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME')."';");
// add some lang verfy messages
$this->document->addScriptDeclaration("
// set the snippet from gitHub
@ -255,16 +260,23 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
setTimeout(function(){
btn.prop('disabled', false);
}, 3000);
var path = btn.data('path');
var type = btn.data('type');
if ('get' === type) {
if ('all' === type) {
var status = btn.data('status');
bulkSnippetGithub(status);
} else if ('bulk' === type) {
checkBulkSnippetGithub();
} else if ('get' === type) {
var path = btn.data('path');
var status = btn.data('status');
setSnippetGithub(path, status);
} else {
var path = btn.data('path');
getSnippetModal(path, type);
}
});
});
// load every thing once ready
jQuery(document).ajaxStop(function () {
if (0 === jQuery.active) {
@ -383,28 +395,28 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
function setDataButtons(snippet, key, status) {
var html = '<div class=\"uk-button-group uk-width-1-1 uk-margin-small-bottom\">';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"usage\" data-uk-tooltip title=\"'+lang_Usage_Tooltip+'\"><i class=\"uk-icon-info\"></i> '+lang_Usage+'</button>';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"description\" data-uk-tooltip title=\"'+lang_Description_Tooltip+'\"><i class=\"uk-icon-sticky-note-o\"></i> '+lang_Description+'</button>';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"snippet\" data-uk-tooltip title=\"'+lang_Snippet_Tooltip+'\"><i class=\"uk-icon-code\"></i> '+lang_Snippet+'</button>';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"usage\" title=\"'+lang_Usage_Tooltip+'\"><i class=\"uk-icon-info\"></i><span class=\"uk-hidden-small\"> '+lang_Usage+'</span></button>';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"description\" title=\"'+lang_Description_Tooltip+'\"><i class=\"uk-icon-sticky-note-o\"></i><span class=\"uk-hidden-small\"> '+lang_Description+'</span></button>';
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"snippet\" title=\"'+lang_Snippet_Tooltip+'\"><i class=\"uk-icon-code\"></i><span class=\"uk-hidden-small\"> '+lang_Snippet+'</span></button>';
html += '</div>';
// return data buttons
return html;
}
function setRefButtons(snippet, key, status, keyID) {
var html = '<div><a class=\"uk-button uk-button-mini uk-button-success uk-margin-small-bottom uk-width-1-1\" href=\"'+snippet.url+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + snippet.name + '</a></div>';
var html = '<div><a class=\"uk-button uk-button-mini uk-button-success uk-margin-small-bottom uk-width-1-1\" href=\"'+snippet.url+'\" target=\"_blank\" title=\"'+lang_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + snippet.name + '</a></div>';
// set the update and review button
html += '<div class=\"uk-button-group uk-width-1-1 uk-margin-small-bottom\">';
html += '<a class=\"uk-button uk-button-small uk-button-primary uk-width-1-2\" href=\"https://github.com/vdm-io/Joomla-Component-Builder-Snippets/blame/master/'+key+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_View_Blame_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> '+lang_View_Blame+'</a>';
html += '<a class=\"uk-button uk-button-small uk-button-primary uk-width-1-2\" href=\"https://github.com/vdm-io/Joomla-Component-Builder-Snippets/blame/master/'+key+'\" target=\"_blank\" title=\"'+lang_View_Blame_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> '+lang_View_Blame+'</a>';
if ('equal' !== status) {
if ('new' === status) {
var tooltip = lang_Get_Snippet_New_Tooltip;
} else {
var tooltip = lang_Get_Snippet_Tooltip;
}
html += '<button id=\"'+keyID+'-getbutton\" class=\"uk-button uk-button-small uk-button-primary uk-width-1-2 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"get\" data-uk-tooltip title=\"'+tooltip+'\"><i class=\"uk-icon-cloud-download\"></i> '+lang_Get_Snippet+'</button>';
html += '<button id=\"'+keyID+'-getbutton\" class=\"uk-button uk-button-small uk-button-primary uk-width-1-2 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"get\" title=\"'+tooltip+'\"><i class=\"uk-icon-cloud-download\"></i> '+lang_Get_Snippet+'</button>';
} else {
html += '<button class=\"uk-button uk-button-small uk-width-1-2\" type=\"button\" disabled data-uk-tooltip title=\"'+lang_Get_Snippet_Dont_Tooltip+'\"><i class=\"uk-icon-cloud-download\"></i> '+lang_Get_Snippet+'</button>';
html += '<button class=\"uk-button uk-button-small uk-width-1-2\" type=\"button\" disabled title=\"'+lang_Get_Snippet_Dont_Tooltip+'\"><i class=\"uk-icon-check-square-o\"></i> '+lang_Dont_Get_Snippet+'</button>';
}
html += '</div>';
// return data buttons
@ -429,13 +441,57 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
var contributor_url = 'https://github.com/vdm-io/Joomla-Component-Builder-Snippets';
}
var html = '<div class=\"uk-button-group uk-width-1-1\">';
html += '<button class=\"uk-button uk-width-1-5 uk-button-mini getreaction\" data-type=\"contributor\" data-path=\"'+key+'\" data-uk-tooltip title=\"'+lang_Contributor_Modal_Tooltip+'\"><i class=\"uk-icon-user\"></i></button>';
html += '<a class=\"uk-button uk-width-4-5 uk-button-mini\" href=\"'+contributor_url+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_Contributor_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + contributor_name + '</a>';
html += '<button class=\"uk-button uk-width-1-5 uk-button-mini getreaction\" data-type=\"contributor\" data-path=\"'+key+'\" title=\"'+lang_Contributor_Modal_Tooltip+'\"><i class=\"uk-icon-user\"></i></button>';
html += '<a class=\"uk-button uk-width-4-5 uk-button-mini\" href=\"'+contributor_url+'\" target=\"_blank\" title=\"'+lang_Contributor_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + contributor_name + '</a>';
html += '</div>';
// return contributor buttons
return html;
}
// do a bulk update
function checkBulkSnippetGithub() {
// check if there is new items
if (bulkItems.new.length === 0) {
jQuery('#bulk-button-new').prop('disabled', true);
jQuery('#bulk-button-new').attr('title', lang_Get_Snippets_New_Tooltip);
jQuery('#bulk-notice-new').show();
}
// check if there is diverged items
if (bulkItems.diverged.length === 0) {
jQuery('#bulk-button-diverged').prop('disabled', true);
jQuery('#bulk-button-diverged').attr('title', lang_Get_Snippets_Diverged_Tooltip);
jQuery('#bulk-notice-diverged').show();
}
// check if there is ahead items
if (bulkItems.ahead.length === 0) {
jQuery('#bulk-button-ahead').prop('disabled', true);
jQuery('#bulk-button-ahead').attr('title', lang_Get_Snippets_Ahead_Tooltip);
jQuery('#bulk-notice-ahead').show();
}
// check if there is behind items
if (bulkItems.behind.length === 0) {
jQuery('#bulk-button-behind').prop('disabled', true);
jQuery('#bulk-button-behind').attr('title', lang_Get_Snippets_Behind_Tooltip);
jQuery('#bulk-notice-behind').show();
}
// check if all we should close the all button
if (bulkItems.behind.length === 0 && bulkItems.new.length === 0 && bulkItems.ahead.length === 0 && bulkItems.diverged.length === 0) {
jQuery('#bulk-button-all').prop('disabled', true);
jQuery('#bulk-button-all').attr('title', lang_Get_Snippets_All_Tooltip);
jQuery('#bulk-notice-all').show();
}
}
// do a bulk update
function bulkSnippetGithub(status) {
UIkit.notify('<b>The Bulk Tool Does not Work Yet!</b><br />We should have the bulk tools ready soon!<br /><br />Check out the console!', {status:'warning'});
if ('all' === status) {
console.log(bulkItems);
} else {
console.log(bulkItems[status]);
}
}
// set the snippet from gitHub
function setSnippetGithub(key, status) {
var message = getConfirmUpdate(status);
@ -480,6 +536,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
// update notice
jQuery('#'+keyID+'-getbutton').attr('title', lang_Get_Snippet_Dont_Tooltip);
jQuery('#'+keyID+'-getbutton').prop('disabled', true);
jQuery('#'+keyID+'-getbutton').html('<i class=\"uk-icon-check-square-o\"></i> ' + lang_Dont_Get_Snippet);
// counter delay just incase
setTimeout(function(){
jQuery('#'+keyID+'-getbutton').prop('disabled', true);