summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-01-26 09:54:42 +0000
committerTed Trask <ttrask01@yahoo.com>2010-01-26 09:54:42 +0000
commit06cac7216f74c580126bfbf9294b8c6bc9d7d0a0 (patch)
treec7fa250f0a71cd8aabd62d4fb40690cd6cccc5d2
parentfdb0862d8b187d5a8a89fa4965e820e8b424356a (diff)
downloadacf-did-06cac7216f74c580126bfbf9294b8c6bc9d7d0a0.tar.bz2
acf-did-06cac7216f74c580126bfbf9294b8c6bc9d7d0a0.tar.xz
Added safety check to see if did has multiple rules.
-rw-r--r--did-assigndefinition-ajax.lsp11
-rw-r--r--did-assigndefinition-html.lsp19
-rw-r--r--did-controller.lua1
3 files changed, 31 insertions, 0 deletions
diff --git a/did-assigndefinition-ajax.lsp b/did-assigndefinition-ajax.lsp
new file mode 100644
index 0000000..1a06cc5
--- /dev/null
+++ b/did-assigndefinition-ajax.lsp
@@ -0,0 +1,11 @@
+<% local view, viewlibrary, page_info = ... %>
+<%
+ require("json")
+ require("html")
+%>
+Status: 200 OK
+Content-Type: "application/json"
+<% io.write("\n") %>
+<%
+ print(json.encode(view))
+%>
diff --git a/did-assigndefinition-html.lsp b/did-assigndefinition-html.lsp
index 8139e17..0f96df5 100644
--- a/did-assigndefinition-html.lsp
+++ b/did-assigndefinition-html.lsp
@@ -5,6 +5,20 @@
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript" src="/js/jquery.autocomplete.js"></script>
<script type="text/javascript">
+ function checkrules() {
+ // Here, we can get the did info and check for complicated rules
+ // $("#diderrtxt").html("Got focus");
+ $.getJSON(
+ '<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>?viewtype=ajax&did='+$("#did").val(),
+ function(data) {
+ // we want to look at data.value.rules.value
+ if (data.value.did.errtxt)
+ $("#diderrtxt").html(data.value.did.errtxt);
+ else if (data.value.rules.value.search("\n") != -1)
+ $("#diderrtxt").html("Warning - this did contains time constraints");
+ }
+ );
+ };
var lastdata = {};
$(function(){
var data = "<% local result = viewlibrary.dispatch_component("listdefinitions", nil, true)
@@ -37,6 +51,11 @@
$("#diderrtxt").html("");
};
});
+ $.ajaxSetup({cache:false});
+ $("#rules").focus(function(event) {
+ // We need to give #did an opportunity to autocomplete on the TAB before checking value
+ window.setTimeout("checkrules();", 10);
+ });
});
</script>
diff --git a/did-controller.lua b/did-controller.lua
index 1d4aed8..77f498c 100644
--- a/did-controller.lua
+++ b/did-controller.lua
@@ -38,6 +38,7 @@ function createdefinition(self)
end
function assigndefinition(self)
+ self.conf.viewtype = self.clientdata.viewtype or self.conf.viewtype
return controllerfunctions.handle_form(self, function() return self.model.getdefinition(self.clientdata.did) end, self.model.updatedefinition, self.clientdata, "Save", "Assign Definition", "Definition Saved")
end