diff --git a/config.xml b/config.xml new file mode 100755 index 000000000..169de1697 --- /dev/null +++ b/config.xml @@ -0,0 +1,12 @@ + + + ps_mbo + + + + + + 0 + 0 + + diff --git a/controllers/admin/AdminPsMboModuleController.php b/controllers/admin/AdminPsMboModuleController.php index 4e94833a7..e9dddf9eb 100644 --- a/controllers/admin/AdminPsMboModuleController.php +++ b/controllers/admin/AdminPsMboModuleController.php @@ -29,6 +29,7 @@ use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; require_once(dirname(__FILE__) . '../../../classes/Addons.php'); @@ -59,6 +60,14 @@ public function initContent() { $admin_webpath = str_ireplace(_PS_CORE_DIR_, '', _PS_ADMIN_DIR_); $admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath); + $container = SymfonyContainer::getInstance(); + $install_url = $container->get('router')->generate('admin_module_import', [], UrlGeneratorInterface::ABSOLUTE_URL); + $notification_count_url = $container->get('router')->generate('admin_module_notification_count', [], UrlGeneratorInterface::ABSOLUTE_URL); + + $parts = parse_url($install_url); + parse_str($parts['query'], $query); + $moduleControllerToken = $query['_token']; + $this->context->smarty->assign(array( 'bootstrap' => 1, 'configure_type' => $this->controller_quick_name, @@ -66,7 +75,10 @@ public function initContent() { 'admin_module_controller_psmbo' => $this->module->controller_name[0], 'admin_module_ajax_url_psmbo' => $this->module->front_controller[0], 'currency_symbol' => Context::getContext()->currency->sign, - 'bo_img' => __PS_BASE_URI__ . $admin_webpath . '/themes/default/img/' + 'bo_img' => __PS_BASE_URI__ . $admin_webpath . '/themes/default/img/', + 'install_url' => $install_url, + 'module_controller_token' => $moduleControllerToken, + 'notification_count_url' => $notification_count_url )); $aJsDef = $aJs = array(); @@ -75,6 +87,7 @@ public function initContent() { // TODO, call vue.min.js $aJs = array( $this->module->js_path . 'vue.js', + $this->module->js_path . 'controllers/module/dropzone.min.js', $this->module->js_path . 'controllers/module/jquery.pstagger.js', $this->module->js_path . 'controllers/module/module.js', $this->module->js_path . 'controllers/module/search.js', diff --git a/ps_mbo.php b/ps_mbo.php index 92408a11b..72b1bd612 100755 --- a/ps_mbo.php +++ b/ps_mbo.php @@ -28,32 +28,35 @@ exit; } +use PrestaShop\PrestaShop\Adapter\SymfonyContainer; +use PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + class ps_mbo extends Module { public $tabs = array( array( - 'name' => 'Module catalog MBO', // One name for all langs + 'name' => 'Module catalog', // One name for all langs 'class_name' => 'AdminPsMboModule', 'visible' => true, 'parent_class_name' => 'AdminModulesSf', ), array( - 'name' => 'Theme catalog MBO 1', // One name for all langs + 'name' => 'Theme catalog', // One name for all langs 'class_name' => 'AdminPsMboTheme', 'visible' => true, 'parent_class_name' => 'AdminParentThemes', ) ); - public function __construct() - { + public function __construct() { $this->name = 'ps_mbo'; - $this->version = '0.0.1'; + $this->version = '1.0.2'; $this->author = 'PrestaShop'; $this->bootstrap = true; parent::__construct(); - $this->displayName = $this->l('Module Back Office'); - $this->description = $this->l('Get all your addons modules !'); + $this->displayName = $this->l('PrestaShop Marketplace in your Back Office'); + $this->description = $this->l('Discover the best PrestaShop modules to optimize your online store.'); $this->controller_name = array('AdminPsMboModule', 'AdminPsMboTheme'); $this->front_controller = array( @@ -75,8 +78,7 @@ public function __construct() * @param none * @return bool */ - public function install() - { + public function install() { if (parent::install() && $this->registerHook('backOfficeHeader') && $this->registerHook('displayDashboardToolbarTopMenu') @@ -129,6 +131,16 @@ public function fetchModulesByController($ajax = false) { } public function hookDisplayAdminEndContent() { + if (Tools::getIsset('controller') && Tools::getValue('controller') == 'AdminPsMboModule') { + $addonsConnect = $this->getAddonsConnectToolbar(); + + $this->context->smarty->assign(array( + 'addons_connect' => $addonsConnect, + )); + + return $this->context->smarty->fetch($this->template_dir . '/include/modal_addons_connect.tpl'); + } + $controller = Tools::getValue('controller'); if ($controller == 'AdminThemes') { $this->context->smarty->assign(array( @@ -147,14 +159,19 @@ public function hookDisplayAdminEndContent() { return $content; } - public function hookDisplayDashboardToolbarTopMenu() { - + if (Tools::getIsset('controller') && Tools::getValue('controller') == 'AdminPsMboModule') { + $addonsConnect = $this->getAddonsConnectToolbar(); + + $this->context->smarty->assign(array( + 'addons_connect' => $addonsConnect, + )); + + return $this->context->smarty->fetch($this->template_dir . '/module-toolbar.tpl'); + } if (!$this->isSymfonyContext()) { - return '
HEYCOUCOU
'; $this->context->smarty->assign(array( -// 'admin_module_ajax_url_psmbo' => $this->front_controller[0], 'admin_module_ajax_url_psmbo' => $this->context->link->getAdminLink('AdminPsMboModule'), 'controller' => Tools::getValue('controller') )); @@ -163,6 +180,27 @@ public function hookDisplayDashboardToolbarTopMenu() { } } + private function getAddonsConnectToolbar() { + $container = SymfonyContainer::getInstance(); + $addonsProvider = $container->get('prestashop.core.admin.data_provider.addons_interface'); + $addonsConnect = array(); + + $authenticated = $addonsProvider->isAddonsAuthenticated(); + + if ($addonsProvider->isAddonsAuthenticated()) { + $addonsEmail = $addonsProvider->getAddonsEmail(); + return array( + 'connected' => true, + 'email' => $addonsEmail['username_addons'], + 'logout_url' => $container->get('router')->generate('admin_addons_logout', [], UrlGeneratorInterface::ABSOLUTE_URL) + ); + } else { + return array( + 'connected' => false, + 'login_url' => $container->get('router')->generate('admin_addons_login', [], UrlGeneratorInterface::ABSOLUTE_URL) + ); + } + } private function installTab() { $tab = new Tab(); @@ -196,8 +234,7 @@ private function installTab() { * @param none * @return bool */ - public function uninstall() - { + public function uninstall() { // unregister hook if (parent::uninstall()) { return true; @@ -214,8 +251,7 @@ public function uninstall() * @param none * @return none */ - public function setMedia($aJsDef, $aJs, $aCss) - { + public function setMedia($aJsDef, $aJs, $aCss) { Media::addJsDef($aJsDef); $this->context->controller->addCSS($aCss); $this->context->controller->addJS($aJs); @@ -249,10 +285,6 @@ public function getModules($filter_modules_list, $tracking_source) { $all_modules = Module::getModulesOnDisk(true); $modules_list = array(); - // TODO REMOVE THESE LINES $filter_modules_list - $filter_modules_list[] = 'export2bizrate'; - $filter_modules_list[] = 'cappasity3d'; - foreach ($all_modules as $module) { $perm = true; if ($module->id) { @@ -284,9 +316,6 @@ protected function getPaymentMboModules() { $active_list = array(); $unactive_list = array(); foreach ($modulesList as $key => $module) { -// if (in_array($module->name, $this->list_partners_modules)) { -// $modulesList[$key]->type = 'addonsPartner'; -// } if (isset($module->description_full) && trim($module->description_full) != '') { $module->show_quick_view = true; } @@ -315,8 +344,7 @@ protected function getPaymentMboModules() { } - public function fillModuleData(&$module, $output_type = 'link', $back = null, $install_source_tracking = false) - { + public function fillModuleData(&$module, $output_type = 'link', $back = null, $install_source_tracking = false) { /** @var Module $obj */ $obj = null; if ($module->onclick_option) { @@ -369,8 +397,7 @@ public function fillModuleData(&$module, $output_type = 'link', $back = null, $i * @param string|bool $install_source_tracking * @return string|array */ - public function displayModuleOptions($module, $output_type = 'link', $back = null, $install_source_tracking = false) - { + public function displayModuleOptions($module, $output_type = 'link', $back = null, $install_source_tracking = false) { if (!isset($module->enable_device)) { $module->enable_device = Context::DEVICE_COMPUTER | Context::DEVICE_TABLET | Context::DEVICE_MOBILE; } diff --git a/views/css/controllers/module/module.css b/views/css/controllers/module/module.css index 25384c8e8..55757ccc5 100644 --- a/views/css/controllers/module/module.css +++ b/views/css/controllers/module/module.css @@ -193,4 +193,112 @@ .link-leveltwo>.link, .menu .main-tab .submenu a, -#nav-sidebar ul.menu li.maintab ul.submenu li a { font-size: .75rem!important; } \ No newline at end of file +#nav-sidebar ul.menu li.maintab ul.submenu li a { font-size: .75rem!important; } + +.bootstrap .btn { + border-width: 1px; + font-weight: 600; + white-space: nowrap; + display: inline-block; + text-align: center; + vertical-align: middle; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + border: 1px solid transparent; + padding: .375rem .838rem; + font-size: .875rem; + line-height: 1.5; + transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; + border-radius: .063rem; +} + +.bootstrap .btn.btn-primary { + color: #fff; + background-color: #25b9d7; + border-color: #25b9d7; + box-shadow: none; + text-transform: none; + margin-right: 10px; +} + +.bootstrap .btn-outline-secondary { + color: #6c868e!important; + background-color: transparent; + background-image: none; + border-color: #6c868e; + margin-right: 10px; +} + +.bootstrap #toolbar-nav { margin-top: 30px; } +.modal-backdrop.fade { opacity: .5!important; } +.modal.fade .modal-dialog { margin: 8rem auto!important; } +h4.modal-title { + display: inline-block; + vertical-align: top; + margin-bottom: 0; + line-height: 1.5; + font-size: 1.125rem; + font-family: Open Sans,Helvetica,Arial,sans-serif; + font-weight: 700; + color: #363a41; + margin-top: 0; +} +#module-modal-addons-connect .modal-header .close, +#module-modal-import-closing-cross { + padding: 1.875rem; + font-size: 2rem; + margin: -1.875rem -1.875rem -1.875rem auto; + float: right; + font-weight: 700; + line-height: 1; + color: #000; + text-shadow: 0 1px 0 #fff; + opacity: .5; +} + +#module-addons-connect-email, #module-addons-connect-password { + padding: .375rem .4375rem; + display: block; + width: 100%; + font-size: .875rem; + line-height: 1.5; + color: #363a41; + background-color: #fff; + background-clip: padding-box; + border: 1px solid #bbcdd2; + border-radius: 0; + box-shadow: none; + transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out; +} + +.modal-content { border-radius: 0px; } + +.notification-container { + line-height: 1.5rem; + height: 1.5rem; + vertical-align: middle; + cursor: pointer; + color: #6c868e; + float: right; + position: relative; +} + +.notification-counter { + display: inline-block; + line-height: .875rem; + height: .875rem; + vertical-align: middle; + position: absolute; + color: #fff; + background: #cd9321; + font-size: .5625rem; + padding: 0 .25rem; + border-radius: 1rem; + top: -.063rem; + right: auto; +} + +#help-container .page-wrap, #main-nav { margin-top: 30px!important; } +.pstaggerTagsWrapper { padding: 0.3rem 0.4rem!important; } \ No newline at end of file diff --git a/views/js/controllers/module/dropzone.min.js b/views/js/controllers/module/dropzone.min.js new file mode 100644 index 000000000..03a43f7c2 --- /dev/null +++ b/views/js/controllers/module/dropzone.min.js @@ -0,0 +1 @@ +!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];if(!g._resolving&&!g.exports){var h={};h.exports={},h.client=h.component=!0,g._resolving=!0,g.call(this,h.exports,a.relative(e),h),delete g._resolving,g.exports=h.exports}return g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],d=0;dd;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("dropzone/index.js",function(a,b,c){c.exports=b("./lib/dropzone.js")}),a.register("dropzone/lib/dropzone.js",function(a,b,c){(function(){var a,d,e,f,g,h,i,j,k={}.hasOwnProperty,l=function(a,b){function c(){this.constructor=a}for(var d in b)k.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},m=[].slice;d="undefined"!=typeof Emitter&&null!==Emitter?Emitter:b("emitter"),i=function(){},a=function(a){function b(a,d){var e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),this.clickableElements=[],this.listeners=[],this.files=[],"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),this.element.dropzone=this,e=null!=(g=b.optionsForElement(this.element))?g:{},this.options=c({},this.defaultOptions,e,null!=d?d:{}),this.options.forceFallback||!b.isBrowserSupported())return this.options.fallback.call(this);if(null==this.options.url&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptedFiles&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");this.options.acceptedMimeTypes&&(this.options.acceptedFiles=this.options.acceptedMimeTypes,delete this.options.acceptedMimeTypes),this.options.method=this.options.method.toUpperCase(),(f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.options.clickable&&(this.clickableElements=this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable")),this.init()}var c;return l(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded","maxfilesreached"],b.prototype.defaultOptions={url:null,method:"post",withCredentials:!1,parallelUploads:2,uploadMultiple:!1,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,maxFiles:null,params:{},clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,acceptedMimeTypes:null,autoProcessQueue:!0,addRemoveLinks:!1,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You can not upload any more files.",accept:function(a,b){return b()},init:function(){return i},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )dz-message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:i,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},paste:i,reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p=this;for(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),a.previewElement=b.createElement(this.options.previewTemplate.trim()),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),l=a.previewElement.querySelectorAll("[data-dz-name]"),f=0,i=l.length;i>f;f++)c=l[f],c.textContent=a.name;for(m=a.previewElement.querySelectorAll("[data-dz-size]"),g=0,j=m.length;j>g;g++)c=m[g],c.innerHTML=this.filesize(a.size);for(this.options.addRemoveLinks&&(a._removeLink=b.createElement(''+this.options.dictRemoveFile+""),a.previewElement.appendChild(a._removeLink)),d=function(c){return c.preventDefault(),c.stopPropagation(),a.status===b.UPLOADING?b.confirm(p.options.dictCancelUploadConfirmation,function(){return p.removeFile(a)}):p.options.dictRemoveFileConfirmation?b.confirm(p.options.dictRemoveFileConfirmation,function(){return p.removeFile(a)}):p.removeFile(a)},n=a.previewElement.querySelectorAll("[data-dz-remove]"),o=[],h=0,k=n.length;k>h;h++)e=n[h],o.push(e.addEventListener("click",d));return o},removedfile:function(a){var b;return null!=(b=a.previewElement)&&b.parentNode.removeChild(a.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(a,b){var c,d,e,f,g;for(a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),f=a.previewElement.querySelectorAll("[data-dz-thumbnail]"),g=[],d=0,e=f.length;e>d;d++)c=f[d],c.alt=a.name,g.push(c.src=b);return g},error:function(a,b){var c,d,e,f,g;for(a.previewElement.classList.add("dz-error"),"String"!=typeof b&&b.error&&(b=b.error),f=a.previewElement.querySelectorAll("[data-dz-errormessage]"),g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.textContent=b);return g},errormultiple:i,processing:function(a){return a.previewElement.classList.add("dz-processing"),a._removeLink?a._removeLink.textContent=this.options.dictCancelUpload:void 0},processingmultiple:i,uploadprogress:function(a,b){var c,d,e,f,g;for(f=a.previewElement.querySelectorAll("[data-dz-uploadprogress]"),g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.style.width=""+b+"%");return g},totaluploadprogress:i,sending:i,sendingmultiple:i,success:function(a){return a.previewElement.classList.add("dz-success")},successmultiple:i,canceled:function(a){return this.emit("error",a,"Upload canceled.")},canceledmultiple:i,complete:function(a){return a._removeLink?a._removeLink.textContent=this.options.dictRemoveFile:void 0},completemultiple:i,maxfilesexceeded:i,maxfilesreached:i,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},c=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?m.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},b.prototype.getAcceptedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted&&e.push(a);return e},b.prototype.getRejectedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted||e.push(a);return e},b.prototype.getQueuedFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.QUEUED&&f.push(a);return f},b.prototype.getUploadingFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.UPLOADING&&f.push(a);return f},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),(null==i.options.maxFiles||i.options.maxFiles>1)&&i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedFiles&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedFiles),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a,b,c,e;if(b=i.hiddenFileInput.files,b.length)for(c=0,e=b.length;e>c;c++)a=b[c],i.addFile(a);return d()})},d()),this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(){return i.updateTotalUploadProgress()}),this.on("removedfile",function(){return i.updateTotalUploadProgress()}),this.on("canceled",function(a){return i.emit("complete",a)}),this.on("complete",function(){return 0===i.getUploadingFiles().length&&0===i.getQueuedFiles().length?setTimeout(function(){return i.emit("queuecomplete")},0):void 0}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){var b;try{b=a.dataTransfer.effectAllowed}catch(d){}return a.dataTransfer.dropEffect="move"===b||"linkMove"===b?"move":"copy",c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a)},dragend:function(a){return i.emit("dragend",a)},paste:function(a){return c(a),i.paste(a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.destroy=function(){var a;return this.disable(),this.removeAllFiles(!0),(null!=(a=this.hiddenFileInput)?a.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,b.instances.splice(b.instances.indexOf(this),1)},b.prototype.updateTotalUploadProgress=function(){var a,b,c,d,e,f,g,h;if(d=0,c=0,a=this.getAcceptedFiles(),a.length){for(h=this.getAcceptedFiles(),f=0,g=h.length;g>f;f++)b=h[f],d+=b.upload.bytesSent,c+=b.upload.total;e=100*d/c}else e=100;return this.emit("totaluploadprogress",e,c,d)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){var a,b,c,d,e;for(this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.cancelUpload(a));return e},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=109951162777.6?(a/=109951162777.6,b="TiB"):a>=107374182.4?(a/=107374182.4,b="GiB"):a>=104857.6?(a/=104857.6,b="MiB"):a>=102.4?(a/=102.4,b="KiB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype._updateMaxFilesReachedClass=function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")},b.prototype.drop=function(a){var b,c;a.dataTransfer&&(this.emit("drop",a),b=a.dataTransfer.files,b.length&&(c=a.dataTransfer.items,c&&c.length&&null!=c[0].webkitGetAsEntry?this._addFilesFromItems(c):this.handleFiles(b)))},b.prototype.paste=function(a){},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype._addFilesFromItems=function(a){var b,c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],null!=c.webkitGetAsEntry&&(b=c.webkitGetAsEntry())?b.isFile?f.push(this.addFile(c.getAsFile())):b.isDirectory?f.push(this._addFilesFromDirectory(b,b.name)):f.push(void 0):null!=c.getAsFile?null==c.kind||"file"===c.kind?f.push(this.addFile(c.getAsFile())):f.push(void 0):f.push(void 0);return f},b.prototype._addFilesFromDirectory=function(a,b){var c,d,e=this;return c=a.createReader(),d=function(a){var c,d,f;for(d=0,f=a.length;f>d;d++)c=a[d],c.isFile?c.file(function(a){return e.options.ignoreHiddenFiles&&"."===a.name.substring(0,1)?void 0:(a.fullPath=""+b+"/"+a.name,e.addFile(a))}):c.isDirectory&&e._addFilesFromDirectory(c,""+b+"/"+c.name)},c.readEntries(d,function(a){return"undefined"!=typeof console&&null!==console?"function"==typeof console.log?console.log(a):void 0:void 0})},b.prototype.accept=function(a,c){return a.size>1024*this.options.maxFilesize*1024?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidFile(a,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(c(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",a)):this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var c=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),a.status=b.ADDED,this.emit("addedfile",a),this._enqueueThumbnail(a),this.accept(a,function(b){return b?(a.accepted=!1,c._errorProcessing([a],b)):c.enqueueFile(a),c._updateMaxFilesReachedClass()})},b.prototype.enqueueFiles=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)b=a[c],this.enqueueFile(b);return null},b.prototype.enqueueFile=function(a){var c=this;if(a.accepted=!0,a.status!==b.ADDED)throw new Error("This file can't be queued because it has already been processed or was rejected.");return a.status=b.QUEUED,this.options.autoProcessQueue?setTimeout(function(){return c.processQueue()},0):void 0},b.prototype._thumbnailQueue=[],b.prototype._processingThumbnail=!1,b.prototype._enqueueThumbnail=function(a){var b=this;return this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*this.options.maxThumbnailFilesize*1024?(this._thumbnailQueue.push(a),setTimeout(function(){return b._processThumbnailQueue()},0)):void 0},b.prototype._processThumbnailQueue=function(){var a=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length)return this._processingThumbnail=!0,this.createThumbnail(this._thumbnailQueue.shift(),function(){return a._processingThumbnail=!1,a._processThumbnailQueue()})},b.prototype.removeFile=function(a){return a.status===b.UPLOADING&&this.cancelUpload(a),this.files=j(this.files,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(a){var c,d,e,f;for(null==a&&(a=!1),f=this.files.slice(),d=0,e=f.length;e>d;d++)c=f[d],(c.status!==b.UPLOADING||a)&&this.removeFile(c);return null},b.prototype.createThumbnail=function(a,b){var c,d=this;return c=new FileReader,c.onload=function(){var e;return e=document.createElement("img"),e.onload=function(){var c,f,g,i,j,k,l,m;return a.width=e.width,a.height=e.height,g=d.options.resize.call(d,a),null==g.trgWidth&&(g.trgWidth=d.options.thumbnailWidth),null==g.trgHeight&&(g.trgHeight=d.options.thumbnailHeight),c=document.createElement("canvas"),f=c.getContext("2d"),c.width=g.trgWidth,c.height=g.trgHeight,h(f,e,null!=(j=g.srcX)?j:0,null!=(k=g.srcY)?k:0,g.srcWidth,g.srcHeight,null!=(l=g.trgX)?l:0,null!=(m=g.trgY)?m:0,g.trgWidth,g.trgHeight),i=c.toDataURL("image/png"),d.emit("thumbnail",a,i),null!=b?b():void 0},e.src=c.result},c.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c,d;if(b=this.options.parallelUploads,c=this.getUploadingFiles().length,a=c,!(c>=b)&&(d=this.getQueuedFiles(),d.length>0)){if(this.options.uploadMultiple)return this.processFiles(d.slice(0,b-c));for(;b>a;){if(!d.length)return;this.processFile(d.shift()),a++}}},b.prototype.processFile=function(a){return this.processFiles([a])},b.prototype.processFiles=function(a){var c,d,e;for(d=0,e=a.length;e>d;d++)c=a[d],c.processing=!0,c.status=b.UPLOADING,this.emit("processing",c);return this.options.uploadMultiple&&this.emit("processingmultiple",a),this.uploadFiles(a)},b.prototype._getFilesWithXhr=function(a){var b,c;return c=function(){var c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)b=e[c],b.xhr===a&&f.push(b);return f}.call(this)},b.prototype.cancelUpload=function(a){var c,d,e,f,g,h,i;if(a.status===b.UPLOADING){for(d=this._getFilesWithXhr(a.xhr),e=0,g=d.length;g>e;e++)c=d[e],c.status=b.CANCELED;for(a.xhr.abort(),f=0,h=d.length;h>f;f++)c=d[f],this.emit("canceled",c);this.options.uploadMultiple&&this.emit("canceledmultiple",d)}else((i=a.status)===b.ADDED||i===b.QUEUED)&&(a.status=b.CANCELED,this.emit("canceled",a),this.options.uploadMultiple&&this.emit("canceledmultiple",[a]));return this.options.autoProcessQueue?this.processQueue():void 0},b.prototype.uploadFile=function(a){return this.uploadFiles([a])},b.prototype.uploadFiles=function(a){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I=this;for(s=new XMLHttpRequest,t=0,x=a.length;x>t;t++)d=a[t],d.xhr=s;s.open(this.options.method,this.options.url,!0),s.withCredentials=!!this.options.withCredentials,p=null,f=function(){var b,c,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],e.push(I._errorProcessing(a,p||I.options.dictResponseError.replace("{{statusCode}}",s.status),s));return e},q=function(b){var c,e,f,g,h,i,j,k,l;if(null!=b)for(e=100*b.loaded/b.total,f=0,i=a.length;i>f;f++)d=a[f],d.upload={progress:e,total:b.total,bytesSent:b.loaded};else{for(c=!0,e=100,g=0,j=a.length;j>g;g++)d=a[g],(100!==d.upload.progress||d.upload.bytesSent!==d.upload.total)&&(c=!1),d.upload.progress=e,d.upload.bytesSent=d.upload.total;if(c)return}for(l=[],h=0,k=a.length;k>h;h++)d=a[h],l.push(I.emit("uploadprogress",d,e,d.upload.bytesSent));return l},s.onload=function(c){var d;if(a[0].status!==b.CANCELED&&4===s.readyState){if(p=s.responseText,s.getResponseHeader("content-type")&&~s.getResponseHeader("content-type").indexOf("application/json"))try{p=JSON.parse(p)}catch(e){c=e,p="Invalid JSON response from server."}return q(),200<=(d=s.status)&&300>d?I._finished(a,p,c):f()}},s.onerror=function(){return a[0].status!==b.CANCELED?f():void 0},o=null!=(D=s.upload)?D:s,o.onprogress=q,i={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"},this.options.headers&&c(i,this.options.headers);for(g in i)h=i[g],s.setRequestHeader(g,h);if(e=new FormData,this.options.params){E=this.options.params;for(m in E)r=E[m],e.append(m,r)}for(u=0,y=a.length;y>u;u++)d=a[u],this.emit("sending",d,s,e);if(this.options.uploadMultiple&&this.emit("sendingmultiple",a,s,e),"FORM"===this.element.tagName)for(F=this.element.querySelectorAll("input, textarea, select, button"),v=0,z=F.length;z>v;v++)if(j=F[v],k=j.getAttribute("name"),l=j.getAttribute("type"),"SELECT"===j.tagName&&j.hasAttribute("multiple"))for(G=j.options,w=0,A=G.length;A>w;w++)n=G[w],n.selected&&e.append(k,n.value);else(!l||"checkbox"!==(H=l.toLowerCase())&&"radio"!==H||j.checked)&&e.append(k,j.value);for(C=0,B=a.length;B>C;C++)d=a[C],e.append(""+this.options.paramName+(this.options.uploadMultiple?"[]":""),d,d.name);return s.send(e)},b.prototype._finished=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.SUCCESS,this.emit("success",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("successmultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b.prototype._errorProcessing=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.ERROR,this.emit("error",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("errormultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b}(d),a.version="3.8.3",a.options={},a.optionsForElement=function(b){return b.getAttribute("id")?a.options[e(b.getAttribute("id"))]:void 0},a.instances=[],a.forElement=function(a){if("string"==typeof a&&(a=document.querySelector(a)),null==(null!=a?a.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return a.dropzone},a.autoDiscover=!0,a.discover=function(){var b,c,d,e,f,g;for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],b=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},b(document.getElementsByTagName("div")),b(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)c=d[e],a.optionsForElement(c)!==!1?g.push(new a(c)):g.push(void 0);return g},a.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],a.isBrowserSupported=function(){var b,c,d,e,f;if(b=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=a.blacklistedBrowsers,d=0,e=f.length;e>d;d++)c=f[d],c.test(navigator.userAgent)&&(b=!1);else b=!1;else b=!1;return b},j=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},e=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},a.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},a.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},a.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},a.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},a.confirm=function(a,b,c){return window.confirm(a)?b():null!=c?c():void 0},a.isValidFile=function(a,b){var c,d,e,f,g;if(!b)return!0;for(b=b.split(","),d=a.type,c=d.replace(/\/.*$/,""),f=0,g=b.length;g>f;f++)if(e=b[f],e=e.trim(),"."===e.charAt(0)){if(-1!==a.name.toLowerCase().indexOf(e.toLowerCase(),a.name.length-e.length))return!0}else if(/\/\*$/.test(e)){if(c===e.replace(/\/.*$/,""))return!0}else if(d===e)return!0;return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(b){return this.each(function(){return new a(this,b)})}),"undefined"!=typeof c&&null!==c?c.exports=a:window.Dropzone=a,a.ADDED="added",a.QUEUED="queued",a.ACCEPTED=a.QUEUED,a.UPLOADING="uploading",a.PROCESSING=a.UPLOADING,a.CANCELED="canceled",a.ERROR="error",a.SUCCESS="success",g=function(a){var b,c,d,e,f,g,h,i,j,k;for(h=a.naturalWidth,g=a.naturalHeight,c=document.createElement("canvas"),c.width=1,c.height=g,d=c.getContext("2d"),d.drawImage(a,0,0),e=d.getImageData(0,0,1,g).data,k=0,f=g,i=g;i>k;)b=e[4*(i-1)+3],0===b?f=i:k=i,i=f+k>>1;return j=i/g,0===j?1:j},h=function(a,b,c,d,e,f,h,i,j,k){var l;return l=g(b),a.drawImage(b,c,d,e,f,h,i,j,k/l)},f=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},a._autoDiscoverFunction=function(){return a.autoDiscover?a.discover():void 0},f(window,a._autoDiscoverFunction)}).call(this)}),a.alias("component-emitter/index.js","dropzone/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),"object"==typeof exports?module.exports=a("dropzone"):"function"==typeof define&&define.amd?define(function(){return a("dropzone")}):this.Dropzone=a("dropzone")}(); \ No newline at end of file diff --git a/views/js/controllers/module/module.js b/views/js/controllers/module/module.js index 7b9ec3125..fc419ff16 100644 --- a/views/js/controllers/module/module.js +++ b/views/js/controllers/module/module.js @@ -39,6 +39,19 @@ $(document).ready(function() { }, getAvgRateClass: function(avg_rate) { return 'module-stars module-star-ranking-grid-' + Math.round(avg_rate) + ' small'; + }, + visibleModules: function() { + var visibleModules = 0; + + if (typeof window.vApp !== 'undefined' && typeof window.vApp.modules !== 'undefined') { + $.each(window.vApp.modules, function(index, value) { + if (value.attributes.visible === true) { + visibleModules++; + } + }); + } + + return visibleModules; } } }); @@ -55,8 +68,6 @@ $(document).ready(function() { window.vApp.modules = parsedData.modules; window.vApp.categories = parsedData.categories; - console.log(window.vApp.categories); - if (typeof filterCategoryTab !== 'undefined') { $.each(window.vApp.modules, function (key, value) { if (value.attributes.tab == filterCategoryTab) { @@ -90,4 +101,21 @@ $(document).ready(function() { return true; }); + var urlToCall = $('#notification_count_url').val(); + if (urlToCall !== '') { + var destinationTab = $("#subtab-AdminModulesNotifications"); + if (destinationTab.length === 0) { + return; + } + + $.getJSON(urlToCall, function(badge) { + destinationTab.append('\ + '+badge.count+'\ + \ + '); + }).fail(function() { + console.error('Could not retrieve module notifications count.'); + }); + } + }); \ No newline at end of file diff --git a/views/js/controllers/module/search.js b/views/js/controllers/module/search.js index fe4e4a980..cda6c7343 100644 --- a/views/js/controllers/module/search.js +++ b/views/js/controllers/module/search.js @@ -432,7 +432,7 @@ var AdminModuleController = function() { this.initAddonsConnect = function () { var self = this; - + // Make addons connect modal ready to be clicked if ($(this.addonsConnectModalBtnSelector).attr('href') == '#') { $(this.addonsConnectModalBtnSelector).attr('data-toggle', 'modal'); @@ -508,21 +508,23 @@ var AdminModuleController = function() { // Change the way Dropzone.js lib handle file input trigger body.on( - 'click', '.dropzone:not('+this.moduleImportSelectFileManualSelector+', '+this.moduleImportSuccessConfigureBtnSelector+')', - function(event, manual_select) { - // if click comes from .module-import-start-select-manual, stop everything - if (typeof manual_select == "undefined") { - event.stopPropagation(); - event.preventDefault(); - } - } + 'click', '.dropzone:not('+this.moduleImportSelectFileManualSelector+', '+this.moduleImportSuccessConfigureBtnSelector+')', + function(event, manual_select) { + // if click comes from .module-import-start-select-manual, stop everything + if (typeof manual_select == "undefined") { + event.stopPropagation(); + event.preventDefault(); + } + } ); body.on('click', this.moduleImportSelectFileManualSelector, function(event) { - event.stopPropagation(); - event.preventDefault(); - // Trigger click on hidden file input, and pass extra data to .dropzone click handler fro it to notice it comes from here - $('.dz-hidden-input').trigger('click', ["manual_select"]); + event.stopPropagation(); + event.preventDefault(); + + // Trigger click on hidden file input, and pass extra data to .dropzone click handler fro it to notice it comes from here + $('#importDropzone').trigger('click', ["manual_select"]); +// $('.dz-hidden-input').trigger('click', ["manual_select"]); }); // Handle modal closure @@ -547,38 +549,48 @@ var AdminModuleController = function() { }); // @see: dropzone.js -// var dropzoneOptions = { -// url: 'import' + window.location.search, -// acceptedFiles: '.zip, .tar', -// // The name that will be used to transfer the file -// paramName: 'file_uploaded', -// maxFilesize: 50, // can't be greater than 50Mb because it's an addons limitation -// uploadMultiple: false, -// addRemoveLinks: true, -// dictDefaultMessage: '', -// hiddenInputContainer: self.dropZoneImportZoneSelector, -// addedfile: function() { -// self.animateStartUpload(); -// }, -// processing: function () { -// // Leave it empty since we don't require anything while processing upload -// }, -// error: function (file, message) { -// self.displayOnUploadError(message); -// }, -// complete: function (file) { -// if (file.status !== 'error') { -// var responseObject = jQuery.parseJSON(file.xhr.response); -// if (typeof responseObject.is_configurable === 'undefined') responseObject.is_configurable = null; -// if (typeof responseObject.module_name === 'undefined') responseObject.module_name = null; -// -// self.displayOnUploadDone(responseObject); -// } -// // State that we have finish the process to unlock some actions -// self.isUploadStarted = false; -// } -// }; -// dropzone.dropzone($.extend(dropzoneOptions)); + var dropzoneOptions = { + url: $('#install_url').val(), + acceptedFiles: '.zip, .tar', + // The name that will be used to transfer the file + paramName: 'file_uploaded', + maxFilesize: 50, // can't be greater than 50Mb because it's an addons limitation + uploadMultiple: false, + addRemoveLinks: true, + dictDefaultMessage: '', + hiddenInputContainer: self.dropZoneImportZoneSelector, + addedfile: function() { + self.animateStartUpload(); + }, + processing: function () { + // Leave it empty since we don't require anything while processing upload + }, + sending: function() { + // Prevent JS errors + }, + uploadprogress: function() { + // Prevent JS errors + }, + success: function() { + // Prevent JS errors + }, + error: function (file, message) { + self.displayOnUploadError(message); + }, + complete: function (file) { + if (file.status !== 'error') { + var responseObject = jQuery.parseJSON(file.xhr.response); + if (typeof responseObject.is_configurable === 'undefined') responseObject.is_configurable = null; + if (typeof responseObject.module_name === 'undefined') responseObject.module_name = null; + + self.displayOnUploadDone(responseObject); + } + // State that we have finish the process to unlock some actions + self.isUploadStarted = false; + } + }; + dropzone.dropzone($.extend(dropzoneOptions)); + console.log(dropzone); this.animateStartUpload = function() { // State that we start module upload @@ -602,10 +614,12 @@ var AdminModuleController = function() { self.animateEndUpload(function() { if (result.status === true) { if (result.is_configurable === true) { - var configureLink = self.baseAdminDir + 'module/manage/action/configure/' + result.module_name + window.location.search; + var configureLink = self.baseAdminDir + 'module/manage/action/configure/' + result.module_name + '?_token=' + $('#module_controller_token').val(); $(self.moduleImportSuccessConfigureBtnSelector).attr('href', configureLink); $(self.moduleImportSuccessConfigureBtnSelector).show(); - } + } else { + $('.module-import-success-configure').hide(); + } $(self.moduleImportSuccessSelector).fadeIn(); } else if (typeof result.confirmation_subject !== 'undefined') { self.displayPrestaTrustStep(result); diff --git a/views/templates/admin/include/menu_top.tpl b/views/templates/admin/include/menu_top.tpl index 6fabaea34..e95500b96 100644 --- a/views/templates/admin/include/menu_top.tpl +++ b/views/templates/admin/include/menu_top.tpl @@ -49,7 +49,7 @@
- [[ modules.length ]] {l s='modules and services selected for you' d='Admin.Modules.Feature'} + {l s='modules and services selected for you' d='Admin.Modules.Feature'} diff --git a/views/templates/admin/include/modal_addons_connect.tpl b/views/templates/admin/include/modal_addons_connect.tpl new file mode 100644 index 000000000..c4e294154 --- /dev/null +++ b/views/templates/admin/include/modal_addons_connect.tpl @@ -0,0 +1,107 @@ +{** + * 2007-2018 PrestaShop + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * https://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@prestashop.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to http://www.prestashop.com for more information. + * + * @author PrestaShop SA + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + *} + +{if $addons_connect['connected'] === false} + +{else} + +{/if} \ No newline at end of file diff --git a/views/templates/admin/include/modal_confirm_prestatrust.tpl b/views/templates/admin/include/modal_confirm_prestatrust.tpl new file mode 100644 index 000000000..d983e87b1 --- /dev/null +++ b/views/templates/admin/include/modal_confirm_prestatrust.tpl @@ -0,0 +1,48 @@ + diff --git a/views/templates/admin/include/modal_import.tpl b/views/templates/admin/include/modal_import.tpl new file mode 100644 index 000000000..5a896df00 --- /dev/null +++ b/views/templates/admin/include/modal_import.tpl @@ -0,0 +1,94 @@ +{** + * 2007-2018 PrestaShop + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * https://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@prestashop.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to http://www.prestashop.com for more information. + * + * @author PrestaShop SA + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + *} + diff --git a/views/templates/admin/module-toolbar.tpl b/views/templates/admin/module-toolbar.tpl new file mode 100644 index 000000000..71ac6e5c2 --- /dev/null +++ b/views/templates/admin/module-toolbar.tpl @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/views/templates/admin/page.tpl b/views/templates/admin/page.tpl index ef2375bb6..4871012f1 100644 --- a/views/templates/admin/page.tpl +++ b/views/templates/admin/page.tpl @@ -24,6 +24,8 @@ *} {if isset($filterCategoryTab)} @@ -136,13 +138,21 @@ {l s='Exit to PrestaShop Addons Marketplace'}
{l s='See all results for your search on'}
- {l s='PrestaShop Addons Marketplace'} + {l s='PrestaShop Addons Marketplace'}
+ + + + + + {include file="./include/modal_import.tpl"} + {include file="./include/modal_confirm_prestatrust.tpl"} +