BUG 13546 "Creacion de una nueva plantilla sin..." SOLVED

- Creacion de una nueva plantilla sin nombre.
- Problema resuelto, cuando se crea una nueva plantilla y no se coloca nada en la caja de texto, al hacer click en el boton
  "create" le mostrara un mensaje indicando que introduzca un nombre. Cuando se tiene creado varios plantillas y se quiere
  crear uno que ya existe, se mostrara un mensaje indicando que el file ya existe.
This commit is contained in:
Luis Fernando Saisa Lopez
2014-07-17 11:24:44 -04:00
parent 95f3dfbd0d
commit c9a90446fa
2 changed files with 62 additions and 17 deletions

View File

@@ -695,6 +695,28 @@ try {
//$json = new Services_JSON(); //$json = new Services_JSON();
$sOutput = Bootstrap::json_encode($response); $sOutput = Bootstrap::json_encode($response);
break; break;
case "verifyNameFile":
$response = array();
$status = "OK";
$filename = $_POST["filename"];
$pathDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST["pro_uid"] . PATH_SEP;
if (is_dir($pathDirectory)) {
$myDirectory = opendir($pathDirectory);
while ($myFile = readdir($myDirectory)) {
if ($myFile == $filename) {
$status = "ERROR";
}
}
closedir($myDirectory);
}
$response["status"] = $status;
echo Bootstrap::json_encode($response);
break;
} }
if (isset($sOutput)) { if (isset($sOutput)) {
die($sOutput); die($sOutput);

View File

@@ -152,25 +152,48 @@ function showCreateEmptyOptions(e, MAIN_DIRECTORY){
} }
function saveEmptyFile(){ function saveEmptyFile(){
var fileName = getField('emptyfilename').value + ".html"; var fileName = getField("emptyfilename").value.trim();
fileName = fileName.trim();
var oRPC = new leimnud.module.rpc.xmlhttp({ if(fileName != "") {
url : 'processes_Ajax', fileName = fileName + ".html";
args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent=' fileName = fileName.trim();
});
oRPC.callback = function(rpc){ var rpcAjax = new leimnud.module.rpc.xmlhttp({
showCreateEmptyOptionsPanel.remove(); url: "processes_Ajax",
/// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); method: "POST",
if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) { args: "action=verifyNameFile&filename=" + fileName + "&pro_uid=" + CURRENT_PRO_UID + "&MAIN_DIRECTORY=" + CURRENT_MAIN_DIRECTORY + "&fcontent="
goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, ''); });
} else {
goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); rpcAjax.callback = function (rpc)
} {
editFile(CURRENT_PRO_UID, fileName) var response = rpc.xmlhttp.responseText.parseJSON();
}.extend(this); var status = response.status;
oRPC.make();
if (status == "OK") {
var oRPC = new leimnud.module.rpc.xmlhttp({
url : 'processes_Ajax',
args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent='
});
oRPC.callback = function(rpc){
showCreateEmptyOptionsPanel.remove();
/// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', '');
if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) {
goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, '');
} else {
goToDirectory(CURRENT_PRO_UID, 'mailTemplates', '');
}
editFile(CURRENT_PRO_UID, fileName)
}.extend(this);
oRPC.make();
} else {
new leimnud.module.app.alert().make({label: "The file exists."});
}
}.extend(this);
rpcAjax.make();
} else {
new leimnud.module.app.alert().make({label: "File name required."});
}
} }
function xReaload(){ function xReaload(){