Add the start of dialog processing to the test client. At this point the dialogs display, but will fail when trying to submit them.
This commit is contained in:
parent
2543746822
commit
7638aa9813
@ -76,6 +76,67 @@ class G3_Client_Controller extends Template_Controller {
|
|||||||
print $this->_get_detail($resource);
|
print $this->_get_detail($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __call($function, $args) {
|
||||||
|
$path = $this->input->get("path");
|
||||||
|
$resource = G3Remote::instance()->get_resource("gallery/$path");
|
||||||
|
|
||||||
|
$this->auto_render = false;
|
||||||
|
switch ($function) {
|
||||||
|
case "edit_album":
|
||||||
|
case "edit_photo":
|
||||||
|
$readonly = empty($resource->path) ? "readonly" : "";
|
||||||
|
$form = array("name" => array("value" => $resource->name, "readonly" => $readonly),
|
||||||
|
"description" => array("value" => $resource->description,
|
||||||
|
"readonly" => $readonly),
|
||||||
|
"slug" => array("value" => $resource->internet_address,
|
||||||
|
"readonly" => $readonly),
|
||||||
|
"title" => array("value" => $resource->title, "readonly" => $readonly));
|
||||||
|
$errors = array_fill_keys(array_keys($form), "");
|
||||||
|
|
||||||
|
if ($_POST) {
|
||||||
|
} else {
|
||||||
|
$v = new View("edit.html");
|
||||||
|
$v->form = $form;
|
||||||
|
$v->errors = $errors;
|
||||||
|
$v->path = "g3_client/$function/?path=$path";
|
||||||
|
$v->type = $resource->type;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "add_album":
|
||||||
|
case "add_photo":
|
||||||
|
$errors = $form = array(
|
||||||
|
"name" => "",
|
||||||
|
"description" => "",
|
||||||
|
"slug" => "",
|
||||||
|
"image_file" => "",
|
||||||
|
"title" => "");
|
||||||
|
if ($_POST) {
|
||||||
|
} else {
|
||||||
|
$v = new View("add.html");
|
||||||
|
$v->form = $form;
|
||||||
|
$v->errors = $errors;
|
||||||
|
$v->path = "g3_client/$function/?path=$path";
|
||||||
|
$v->function = $function;
|
||||||
|
$function_parts = explode("_", $function);
|
||||||
|
$v->type = $function_parts[1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "delete_album":
|
||||||
|
case "delete_photo":
|
||||||
|
if ($_POST) {
|
||||||
|
} else {
|
||||||
|
$v = new View("delete.html");
|
||||||
|
$v->title = $resource->title;
|
||||||
|
$v->path = "g3_client/$function/?path=$path";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Kohana_404_Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
print $v;
|
||||||
|
}
|
||||||
|
|
||||||
private function _get_album_tree($resource) {
|
private function _get_album_tree($resource) {
|
||||||
$v = new View("tree_part.html");
|
$v = new View("tree_part.html");
|
||||||
$v->element = (object)array("title" => $resource->title, "path" => $resource->path);
|
$v->element = (object)array("title" => $resource->title, "path" => $resource->path);
|
||||||
@ -105,4 +166,9 @@ class G3_Client_Controller extends Template_Controller {
|
|||||||
}
|
}
|
||||||
return $v;
|
return $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _extract_form_data($resource) {
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
} // End G3 Client Controller
|
} // End G3 Client Controller
|
||||||
|
42
web_client/application/views/add.html.php
Normal file
42
web_client/application/views/add.html.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div id="wc-edit">
|
||||||
|
<?= form::open("<?= $path ?>") ?>
|
||||||
|
<fieldset>
|
||||||
|
<legend style="display: none">Add Resource</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?= form::label("title", "Title:") ?><br/>
|
||||||
|
<?= form::input("title", $form["title"]) ?>
|
||||||
|
<?= empty($errors["title"]) ? "" : "<span class=\"error\">{$errors["title"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("description", "Description:") ?><br/>
|
||||||
|
<?= form::textarea("description", $form["description"]) ?>
|
||||||
|
<?= empty($errors["description"]) ? "" : "<span class=\"error\">{$errors["description"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("name", "Name:") ?><br/>
|
||||||
|
<?= form::input("name", $form["name"]) ?>
|
||||||
|
<?= empty($errors["name"]) ? "" : "<span class=\"error\">{$errors["name"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("slug", "Internet Address:") ?><br/>
|
||||||
|
<?= form::input("slug", $form["slug"]) ?>
|
||||||
|
<?= empty($errors["slug"]) ? "" : "<span class=\"error\">{$errors["slug"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<? if ($function == "add_photo"): ?>
|
||||||
|
<li>
|
||||||
|
<?= form::label("image_file", "Image File:") ?><br/>
|
||||||
|
<?= form::upload("image_file", $form["image_file"]) ?>
|
||||||
|
<?= empty($errors["image_file"]) ? "" : "<span class=\"error\">{$errors["image_file"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<? endif ?>
|
||||||
|
<li style="text-align: center">
|
||||||
|
<?= form::submit("submit", "Add") ?>
|
||||||
|
<?= form::input(array('type'=>'reset','name'=>'reset'), "Reset") ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
27
web_client/application/views/delete.html.php
Normal file
27
web_client/application/views/delete.html.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<script>
|
||||||
|
$("#wc-edit").ready(function() {
|
||||||
|
$("#wc-delete-cancel").click(function(event) {
|
||||||
|
$("#g-dialog").dialog("close");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div id="wc-edit">
|
||||||
|
<?= form::open("<?= $path ?>") ?>
|
||||||
|
<fieldset>
|
||||||
|
<legend style="display: none">Confirm Delete</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Do you really want to delete '<?= $title ?>'. <br/>
|
||||||
|
Press <b>Yes</b> to continue, <b>Cancel</b> to quit
|
||||||
|
</li>
|
||||||
|
<li style="text-align: center">
|
||||||
|
<?= form::submit("submit", "Yes", "id=\"wc-delete-continue\"") ?>
|
||||||
|
<?= form::submit("submit", "Cancel", "id=\"wc-delete-cancel\"") ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
35
web_client/application/views/edit.html.php
Normal file
35
web_client/application/views/edit.html.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div id="wc-edit">
|
||||||
|
<?= form::open("<?= $path ?>") ?>
|
||||||
|
<fieldset>
|
||||||
|
<legend style="display: none">Update Resource</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?= form::label("title", "Title:") ?><br/>
|
||||||
|
<?= form::input("title", $form["title"]["value"], "readonly={$form["title"]["readonly"]}") ?>
|
||||||
|
<?= empty($errors["title"]) ? "" : "<span class=\"error\">{$errors["title"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("description", "Description:") ?><br/>
|
||||||
|
<?= form::textarea("description", $form["description"]["value"]) ?>
|
||||||
|
<?= empty($errors["description"]) ? "" : "<span class=\"error\">{$errors["description"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("name", "Name:") ?><br/>
|
||||||
|
<?= form::input("name", $form["name"]["value"], "readonly={$form["name"]["readonly"]}") ?>
|
||||||
|
<?= empty($errors["name"]) ? "" : "<span class=\"error\">{$errors["name"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?= form::label("slug", "Internet Address:") ?><br/>
|
||||||
|
<?= form::input("slug", $form["slug"]["value"], "readonly={$form["slug"]["readonly"]}") ?>
|
||||||
|
<?= empty($errors["slug"]) ? "" : "<span class=\"error\">{$errors["slug"]}</span>" ?>
|
||||||
|
</li>
|
||||||
|
<li style="text-align: center">
|
||||||
|
<?= form::submit("submit", "Update") ?>
|
||||||
|
<?= form::input(array('type'=>'reset','name'=>'reset'), "Reset") ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
@ -20,8 +20,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="wc-buttonset wc-buttonset-single ui-helper-clearfix">
|
<div class="wc-buttonset wc-buttonset-single ui-helper-clearfix">
|
||||||
<a href="#" id="add-resource" ref="add_album" class="wc-button ui-state-active ui-corner-left" ><span>Add Album<span></a>
|
<a href="#" id="wc-add-resource" ref="add_album" class="wc-button ui-state-active ui-corner-left" ><span>Add Album</span></a>
|
||||||
<a href="#" class="wc-button ui-state-active wc-button-icon-solo ui-corner-right" title="Resources"><span class="ui-icon ui-icon-triangle-1-s"></span> </a>
|
<a href="#" id="wc-choose-resource" class="wc-button ui-state-active wc-button-icon-solo ui-corner-right" title="Resources">
|
||||||
|
<span class="ui-icon ui-icon-triangle-1-s"></span>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
<div id="wc-resource-list">
|
||||||
|
<ul>
|
||||||
|
<li ref="add_album">Add Album</li>
|
||||||
|
<li ref="add_photo">Add Photo</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="wc-detail">
|
<div id="wc-detail">
|
||||||
|
@ -30,11 +30,30 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#g-dialog {
|
||||||
|
background-color: #666666;
|
||||||
|
color: #FF9933;
|
||||||
|
}
|
||||||
|
|
||||||
form li {
|
form li {
|
||||||
padding-top: .4em;
|
padding-top: .4em;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
form li input[type=text],
|
||||||
|
form li input[type=file],
|
||||||
|
form li textarea {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
form li input[readonly=readonly],
|
||||||
|
form li textarea[readonly=readonly] {
|
||||||
|
background-color: #999999;
|
||||||
|
color: #FF9933;
|
||||||
}
|
}
|
||||||
|
|
||||||
form legend {
|
form legend {
|
||||||
|
color: #FF9933;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@ -256,3 +275,21 @@ button.wc-button {
|
|||||||
.wc-toolbar .wc-button {
|
.wc-toolbar .wc-button {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#wc-resource-list {
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0px 1px 1px 1px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
color: #F6A828;
|
||||||
|
display: none;
|
||||||
|
float: left;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wc-resource-list li {
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
@ -66,6 +66,34 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#wc-choose-resource").live("click", function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
if ($("#wc-resource-list:visible").length) {
|
||||||
|
$("#wc-resource-list").hide();
|
||||||
|
} else {
|
||||||
|
var parent = $(this).parent("div");
|
||||||
|
var width = parent.width();
|
||||||
|
var height = parent.height();
|
||||||
|
var top = parent.position().top;
|
||||||
|
var current_path = $("#wc-add-resource").attr("ref");
|
||||||
|
$("#wc-resource-list li[ref='" + current_path + "']").addClass("ui-selected");
|
||||||
|
$("#wc-resource-list")
|
||||||
|
.css({"top": (top + height - 5) + "px", "width": width + "px"})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#wc-resource-list").live("click", function(event) {
|
||||||
|
var ref = $(event.originalTarget).attr("ref");
|
||||||
|
var text = $(event.originalTarget).text();
|
||||||
|
$("#wc-add-resource span").text(text);
|
||||||
|
$("#wc-add-resource").attr("ref", ref);
|
||||||
|
$("#wc-resource-list").hide();
|
||||||
|
$("#wc-resource-list li.ui-selected").removeClass("ui-selected");
|
||||||
|
});
|
||||||
|
|
||||||
$("#center a.wc-child-link").live("click", function(event) {
|
$("#center a.wc-child-link").live("click", function(event) {
|
||||||
$(".wc-thumb-grid-cell.ui-selected").removeClass("ui-selected");
|
$(".wc-thumb-grid-cell.ui-selected").removeClass("ui-selected");
|
||||||
$(this).parents("li:first").addClass("ui-selected");
|
$(this).parents("li:first").addClass("ui-selected");
|
||||||
@ -77,7 +105,9 @@
|
|||||||
if ($(this).hasClass("ui-state-disabled")) {
|
if ($(this).hasClass("ui-state-disabled")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch ($(this).attr("ref")) {
|
|
||||||
|
var action = $(this).attr("ref");
|
||||||
|
switch (action) {
|
||||||
case "parent":
|
case "parent":
|
||||||
get_detail($("span", this).attr("ref"), _set_active_album);
|
get_detail($("span", this).attr("ref"), _set_active_album);
|
||||||
break;
|
break;
|
||||||
@ -107,6 +137,13 @@
|
|||||||
_set_navigation_buttons();
|
_set_navigation_buttons();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "edit":
|
||||||
|
case "delete":
|
||||||
|
case "add_album":
|
||||||
|
case "add_photo":
|
||||||
|
var url = /^add_.*/.test(action) ? action : action + "_" + resource_type;
|
||||||
|
_open_dialog(url, $("span", this).attr("ref"));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.group("process toolbar button click: " + $(this).attr("ref"));
|
console.group("process toolbar button click: " + $(this).attr("ref"));
|
||||||
console.log(($("span", this).attr("ref")));
|
console.log(($("span", this).attr("ref")));
|
||||||
@ -141,6 +178,55 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _open_dialog(dialog, resource_path) {
|
||||||
|
console.group("_open_dialog(" + dialog + ")");
|
||||||
|
console.log(resource_path);
|
||||||
|
console.groupEnd();
|
||||||
|
$("body").append('<div id="g-dialog"></div>');
|
||||||
|
$("#g-dialog").dialog({
|
||||||
|
model: true,
|
||||||
|
resizable: false,
|
||||||
|
position: "center",
|
||||||
|
close: function() {
|
||||||
|
$("#g-dialog").dialog("destroy").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.get("/g3_client/index.php/g3_client/" + dialog, {path: resource_path}, function(data) {
|
||||||
|
$("#g-dialog").html(data);
|
||||||
|
|
||||||
|
$("#g-dialog").dialog("open");
|
||||||
|
if ($("#g-dialog fieldset legend").length) {
|
||||||
|
$("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#g-dialog form").length) {
|
||||||
|
$("#g-dialog form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
beforeSubmit: function(formData, form, options) {
|
||||||
|
form.find(":submit")
|
||||||
|
.addClass("ui-state-disabled")
|
||||||
|
.attr("disabled", "disabled");
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-dialog form").replaceWith(data.form);
|
||||||
|
$("#g-dialog form :submit").removeClass("ui-state-disabled")
|
||||||
|
.attr("disabled", null);
|
||||||
|
self._ajaxify_dialog();
|
||||||
|
self.form_loaded(null, $("#g-dialog form"));
|
||||||
|
if (typeof data.reset == 'function') {
|
||||||
|
eval(data.reset + '()');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.result == "success") {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function get_detail(path, callback) {
|
function get_detail(path, callback) {
|
||||||
$.get("/g3_client/index.php/g3_client/detail", {path: path}, function(data, textStatus) {
|
$.get("/g3_client/index.php/g3_client/detail", {path: path}, function(data, textStatus) {
|
||||||
$("#wc-detail").html(data);
|
$("#wc-detail").html(data);
|
||||||
@ -172,7 +258,7 @@
|
|||||||
$(".wc-toolbar .ui-icon-eject").attr("ref", parent_path);
|
$(".wc-toolbar .ui-icon-eject").attr("ref", parent_path);
|
||||||
$(".wc-toolbar .ui-icon-pencil").attr("ref", current_path);
|
$(".wc-toolbar .ui-icon-pencil").attr("ref", current_path);
|
||||||
$(".wc-toolbar .ui-icon-trash").attr("ref", current_path);
|
$(".wc-toolbar .ui-icon-trash").attr("ref", current_path);
|
||||||
$(".wc-toolbar #add-resource span")
|
$(".wc-toolbar #wc-add-resource span")
|
||||||
.attr("ref", resource_type == "album" ? current_path : parent_path);
|
.attr("ref", resource_type == "album" ? current_path : parent_path);
|
||||||
|
|
||||||
var paths = _paths[resource_type == "album" ? current_path : parent_path];
|
var paths = _paths[resource_type == "album" ? current_path : parent_path];
|
||||||
|
Reference in New Issue
Block a user