Merged in bugfix/HOR-4039 (pull request #6189)

HOR-4039

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Marco Antonio Nina Mena
2017-11-29 19:41:36 +00:00
committed by Julio Cesar Laura Avendaño

View File

@@ -1,13 +1,13 @@
Ext.onReady(function() { Ext.onReady(function () {
var store = new Ext.data.JsonStore({ var store = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({ proxy: new Ext.data.HttpProxy({
url : '../adminProxy/getListImage', method: 'POST' url: '../adminProxy/getListImage', method: 'POST'
}), }),
root : 'images', root: 'images',
fields : [ fields: [
'name', 'url', 'name', 'url',
{name : 'size', type : 'float'}, {name: 'size', type: 'float'},
{name : 'lastmod', type : 'date', dateFormat: 'timestamp'}, {name: 'lastmod', type: 'date', dateFormat: 'timestamp'},
'thumb_url' 'thumb_url'
] ]
}); });
@@ -38,24 +38,24 @@ Ext.onReady(function() {
); );
var tbar = new Ext.Toolbar(); var tbar = new Ext.Toolbar();
tbar.add({ tbar.add({
text : _('ID_APPLY'), text: _('ID_APPLY'),
icon : '/images/ext/default/accept.png', icon: '/images/ext/default/accept.png',
id : 'tbarAply', id: 'tbarAply',
disabled: true, disabled: true,
handler : function() { handler: function () {
var records = datav.getSelectedRecords(); var records = datav.getSelectedRecords();
if (records.length != 0) { if (records.length != 0) {
if(records.length == 1) { if (records.length == 1) {
var myMask = new Ext.LoadMask(Ext.getBody(), {msg:_('ID_LOADING')}); var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _('ID_LOADING')});
myMask.show(); myMask.show();
var imageName = records[0].data.name; var imageName = records[0].data.name;
Ext.Ajax.request({ Ext.Ajax.request({
url : '../adminProxy/replacementLogo', url: '../adminProxy/replacementLogo',
method : 'post', method: 'post',
params : {nameFunction: 'replacementLogo', NAMELOGO:imageName}, params: {nameFunction: 'replacementLogo', NAMELOGO: imageName},
success : function() { success: function () {
if (typeof parent.parent.Ext != 'undefined') { if (typeof parent.parent.Ext != 'undefined') {
parent.parent.location.href = '../main?st=admin'; parent.parent.location.href = '../main?st=admin';
} }
@@ -66,21 +66,21 @@ Ext.onReady(function() {
}); });
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO')); PMExt.notify(_('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO'));
} }
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECT_AN_IMAGE')); PMExt.notify(_('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
} }
} }
}); });
tbar.add({ tbar.add({
text : _('ID_DELETE'), text: _('ID_DELETE'),
icon : '/images/delete-16x16.gif', icon: '/images/delete-16x16.gif',
id : 'tbarDelete', id: 'tbarDelete',
disabled: true, disabled: true,
handler : function() { handler: function () {
var records = datav.getSelectedRecords(); var records = datav.getSelectedRecords();
var isCurrentLogo = false; var isCurrentLogo = false;
if (records.length != 0) { if (records.length != 0) {
@@ -90,71 +90,71 @@ Ext.onReady(function() {
imgName = imgName + records[i].data.name + ';'; imgName = imgName + records[i].data.name + ';';
} }
Ext.Ajax.request({ Ext.Ajax.request({
url : '../adminProxy/isCurrentLogo', url: '../adminProxy/isCurrentLogo',
method : 'post', method: 'post',
params : { selectLogo : imgName }, params: {selectLogo: imgName},
success : function(response) { success: function (response) {
store.load(); store.load();
oResponse = Ext.decode( response.responseText ); oResponse = Ext.decode(response.responseText);
if (oResponse.success == true) { if (oResponse.success == true) {
Ext.Msg.alert(_('ID_LOGO'), _('ID_SELECTED_IMAGE_IS_LOGO')); Ext.Msg.alert(_('ID_LOGO'), _('ID_SELECTED_IMAGE_IS_LOGO'));
isCurrentLogo = true; isCurrentLogo = true;
} }
} }
}); });
if(isCurrentLogo == false) { if (isCurrentLogo == false) {
Ext.Msg.show({ Ext.Msg.show({
title : _('ID_LOGO'), title: _('ID_LOGO'),
msg : _('ID_DELETE_SELECTED_LOGO'), msg: _('ID_DELETE_SELECTED_LOGO'),
buttons: Ext.Msg.YESNO, buttons: Ext.Msg.YESNO,
fn : function(btn) { fn: function (btn) {
if(btn == 'yes') { if (btn == 'yes') {
Ext.Ajax.request({ Ext.Ajax.request({
url : '../adminProxy/deleteImage', url: '../adminProxy/deleteImage',
method : 'post', method: 'post',
params : {images : imgName}, params: {images: imgName},
success : function(response) { success: function (response) {
store.load(); store.load();
oResponse = Ext.decode( response.responseText ); oResponse = Ext.decode(response.responseText);
if (oResponse.success == true) { if (oResponse.success == true) {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECTED_IMAGE_DELETED')); PMExt.notify(_('ID_NOTICE'), _('ID_SELECTED_IMAGE_DELETED'));
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECTED_IMAGE_IS_LOGO')); PMExt.notify(_('ID_NOTICE'), _('ID_SELECTED_IMAGE_IS_LOGO'));
} }
} }
}); });
} }
}, },
animEl : 'elId', animEl: 'elId',
icon : Ext.MessageBox.QUESTION icon: Ext.MessageBox.QUESTION
}); });
} }
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO')); PMExt.notify(_('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO'));
} }
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECT_AN_IMAGE')); PMExt.notify(_('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
} }
} }
}); });
tbar.add({ tbar.add({
text : _('ID_RESTORE_DEFAULT'), text: _('ID_RESTORE_DEFAULT'),
icon : '/images/icon-pmlogo-15x15.png', icon: '/images/icon-pmlogo-15x15.png',
handler : function() { handler: function () {
var records = datav.getSelectedRecords(); var records = datav.getSelectedRecords();
var myMask = new Ext.LoadMask(Ext.getBody(), {msg : _('ID_LOADING')}); var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _('ID_LOADING')});
myMask.show(); myMask.show();
var imageName = 'name'; var imageName = 'name';
Ext.Ajax.request({ Ext.Ajax.request({
url : '../adminProxy/replacementLogo', url: '../adminProxy/replacementLogo',
method : 'post', method: 'post',
params : {nameFunction: 'restoreLogo', NAMELOGO:imageName}, params: {nameFunction: 'restoreLogo', NAMELOGO: imageName},
success : function() { success: function () {
if (typeof parent.parent.Ext != 'undefined') { if (typeof parent.parent.Ext != 'undefined') {
parent.parent.location.href = '../main?st=admin'; parent.parent.location.href = '../main?st=admin';
} }
@@ -167,29 +167,29 @@ Ext.onReady(function() {
}); });
tbar.add('-', { tbar.add('-', {
text : _('ID_UPLOAD'), text: _('ID_UPLOAD'),
iconCls : 'silk-add', iconCls: 'silk-add',
icon : '/images/import.gif', icon: '/images/import.gif',
handler : function(){ handler: function () {
uploadWin.show(); uploadWin.show();
} }
}) })
var datav = new Ext.DataView({ var datav = new Ext.DataView({
autoScroll : true,
store : store,
tpl : tpl,
autoHeight : false,
height : 800,
multiSelect : true,
autoScroll: true, autoScroll: true,
overClass : 'x-view-over', store: store,
tpl: tpl,
autoHeight: false,
height: 800,
multiSelect: true,
autoScroll: true,
overClass: 'x-view-over',
itemSelector: 'div.thumb-wrap', itemSelector: 'div.thumb-wrap',
emptyText : _('ID_NO_IMAGES_TO_DISPLAY'), emptyText: _('ID_NO_IMAGES_TO_DISPLAY'),
listeners : { listeners: {
selectionchange : { selectionchange: {
fn : function(dv,nodes){ fn: function (dv, nodes) {
var l = nodes.length; var l = nodes.length;
var s = l != 1 ? 's' : ''; var s = l != 1 ? 's' : '';
panelLeft.setTitle(_('PHOTO_GALLERY') + '(' + l + ' ' + _('ID_IMAGE') + s + ' ' + _('ID_SELECTED') + ')'); panelLeft.setTitle(_('PHOTO_GALLERY') + '(' + l + ' ' + _('ID_IMAGE') + s + ' ' + _('ID_SELECTED') + ')');
@@ -214,48 +214,66 @@ Ext.onReady(function() {
}) })
var panelLeft = new Ext.Panel({ var panelLeft = new Ext.Panel({
region : 'center', region: 'center',
id : 'images-view', id: 'images-view',
frame : true, frame: true,
width : 520, width: 520,
autoHeight : true, autoHeight: true,
layout : 'auto', layout: 'auto',
title : _('PHOTO_GALLERY') + '(0 ' + _('ID_IMAGES_SELECTED') + ')', title: _('PHOTO_GALLERY') + '(0 ' + _('ID_IMAGES_SELECTED') + ')',
items : [tbar, datav] items: [tbar, datav]
}); });
var panelRightTop = new Ext.FormPanel({ var panelRightTop = new Ext.FormPanel({
title : _('ID_UPLOAD_IMAGE'), title: _('ID_UPLOAD_IMAGE'),
width : 270, width: 270,
labelAlign : 'right', labelAlign: 'right',
fileUpload : true, fileUpload: true,
frame : true, frame: true,
defaults : { defaults: {
anchor : '90%', anchor: '90%',
allowBlank : false, allowBlank: false,
msgTarget : 'side' msgTarget: 'side'
}, },
items: items:
[ [
{ {
xtype : 'fileuploadfield', xtype: 'fileuploadfield',
emptyText : '', emptyText: '',
fieldLabel : _('ID_IMAGE'), fieldLabel: _('ID_IMAGE'),
buttonText : _('ID_SELECT_FILE'), buttonText: _('ID_SELECT_FILE'),
name : 'img' name: 'img',
validator: function (filePath) {
var flag, btn;
btn = Ext.getCmp('btnUpload');
btn.disable();
filePath = filePath.replace(/^\s|\s$/g, ""); //trims string
if (filePath.match(/([^\/\\]+)\.(gif|png|jpg|jpeg|pjpeg|x-png)$/i)) {
flag = true;
btn.enable();
} else {
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
PMExt.notify(_('ID_ERROR'), messageError);
flag = false;
}
return flag;
}
} }
], ],
buttons : buttons:
[ [
{ {
text : _('ID_UPLOAD'), text: _('ID_UPLOAD'),
handler : function() { id: 'btnUpload',
disabled: true,
handler: function () {
panelRightTop.getForm().submit({ panelRightTop.getForm().submit({
url : '../adminProxy/uploadImage', url: '../adminProxy/uploadImage',
waitMsg : _('ID_LOADING'), waitMsg: _('ID_LOADING'),
waitTitle : "&nbsp;", waitTitle: "&nbsp;",
success : function(form, o) { success: function (form, o) {
obj = Ext.util.JSON.decode(o.response.responseText); obj = Ext.util.JSON.decode(o.response.responseText);
if ((obj.failed == '' || obj.failed == '0') && obj.uploaded != '0') { if ((obj.failed == '' || obj.failed == '0') && obj.uploaded != '0') {
PMExt.notify(_('ID_SUCCESS'), _('ID_YOUR_IMAGE_HAS_BEEN_SUCCESSFULLY')); PMExt.notify(_('ID_SUCCESS'), _('ID_YOUR_IMAGE_HAS_BEEN_SUCCESSFULLY'));
@@ -266,11 +284,11 @@ Ext.onReady(function() {
//| 1-> Fail in the type of the image //| 1-> Fail in the type of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE'); messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
} }
else if(obj.failed == "2") { else if (obj.failed == "2") {
//| 2-> Fail in the size of the image //| 2-> Fail in the size of the image
messageError = _('ID_UPLOADING_IMAGE_WRONG_SIZE'); messageError = _('ID_UPLOADING_IMAGE_WRONG_SIZE');
} }
else if(obj.failed == "3") { else if (obj.failed == "3") {
//| 3-> fail in de mime of the image //| 3-> fail in de mime of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE'); messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
} }
@@ -285,8 +303,8 @@ Ext.onReady(function() {
} }
}, },
{ {
text : _('ID_CANCEL'), text: _('ID_CANCEL'),
handler : function() { handler: function () {
uploadWin.hide(); uploadWin.hide();
} }
} }
@@ -294,37 +312,37 @@ Ext.onReady(function() {
}); });
uploadWin = new Ext.Window({ uploadWin = new Ext.Window({
title : '', title: '',
id : 'uploadWin', id: 'uploadWin',
layout : 'fit', layout: 'fit',
width : 420, width: 420,
height : 140, height: 140,
modal : false, modal: false,
autoScroll : true, autoScroll: true,
closeAction : 'hide', closeAction: 'hide',
maximizable : false, maximizable: false,
resizable : false, resizable: false,
draggable : false, draggable: false,
items : [panelRightTop] items: [panelRightTop]
}); });
var panelRightBottom = new Ext.Panel({ var panelRightBottom = new Ext.Panel({
region : 'east', region: 'east',
title : _('IMAGE_DETAIL'), title: _('IMAGE_DETAIL'),
frame : true, frame: true,
width : 200, width: 200,
height : 255, height: 255,
split : true, split: true,
collapsible : true, collapsible: true,
collapseMode : 'mini', collapseMode: 'mini',
margins : '0 0 0 0', margins: '0 0 0 0',
id : 'panelDetail', id: 'panelDetail',
tpl : tplDetail tpl: tplDetail
}); });
var viewport = new Ext.Viewport({ var viewport = new Ext.Viewport({
layout : 'border', layout: 'border',
autoScroll : false, autoScroll: false,
items : [ panelLeft ] items: [panelLeft]
}); });
}); });