[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - datasourcemanager.js:1.12 jsdav.js:1.3 sitesmanager.js:1.12
Stephan Richter
srichter@cbu.edu
Sun, 23 Mar 2003 08:33:23 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv4156/moztop/content/lib
Modified Files:
datasourcemanager.js jsdav.js sitesmanager.js
Log Message:
Remove works now for Sites and Content Resources. The so-called
'Virtual/Pseudo Folders' just give you a message that you cannot delete
them.
Note that deleting Content Resources works using the DAV DELETE command
now. If you still run Zope 3 with an old zserver.zcml, then you need to
start using the new version that can be copied from zserver.zcml.in.
=== Packages/Moztop/moztop/content/lib/datasourcemanager.js 1.11 => 1.12 ===
--- Packages/Moztop/moztop/content/lib/datasourcemanager.js:1.11 Sat Mar 22 21:20:36 2003
+++ Packages/Moztop/moztop/content/lib/datasourcemanager.js Sun Mar 23 08:32:52 2003
@@ -204,7 +204,7 @@
}
-DataSourceManager.prototype.getNode = function(urn) {
+DataSourceManager.prototype.getResource = function(urn) {
/* Grab a resource using its urn. This method looks through all
datasources to find the resource. */
var tree = document.getElementById(this.treeId);
@@ -224,6 +224,15 @@
DataSourceManager.prototype.openSelectedResource = function() {
/* This function "opens" the selected Tree resource.
+
+ Note: This should be overridden by the implmenting class.
+ */
+
+ return true;
+}
+
+DataSourceManager.prototype.removeSelectedResource = function() {
+ /* This function deletes the selected Tree resource.
Note: This should be overridden by the implmenting class.
*/
=== Packages/Moztop/moztop/content/lib/jsdav.js 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.2 Sat Mar 22 14:36:31 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js Sun Mar 23 08:32:52 2003
@@ -17,43 +17,47 @@
******************************************************************************/
-SitesManager.prototype.DELETE = function(puturl, putcontent) {
+function DELETE(puturl, putcontent) {
/* Deleting a resource on the server */
- var req = new XMLHttpRequest();
+ var request = new XMLHttpRequest();
+
+ if (!putcontent) {
+ putcontent = "";
+ }
function myfunc(e) {
- if (req.responseXML) {
+ if (request.responseXML) {
var serializer = new XMLSerializer();
- var resp = req.responseXML;
+ var resp = request.responseXML;
var str = serializer.serializeToString(d);
dump("\nmade it in PUT\n" + str + "\n");
}
}
- req.onload = myfunc;
- req.open("DELETE", puturl);
- req.setRequestHeader("Content-type", "text/plain");
- req.setRequestHeader("Host", "localhost");
- req.send(putcontent);
+ request.onload = myfunc;
+ request.open("DELETE", puturl);
+ request.setRequestHeader("Content-type", "text/plain");
+ //request.setRequestHeader("Host", "localhost");
+ request.send(putcontent);
return;
}
-SitesManager.prototype.PUT = function () {
+function PUT() {
var puturl = "http://localhost:9700/fooboy3";
var putcontent = "";
- var p = new XMLHttpRequest();
+ var request = new XMLHttpRequest();
var typeheader = "X-Zope-Type-Name"
function myfunc (e) {
- if (p.responseXML) {
+ if (request.responseXML) {
var s = new XMLSerializer();
- var d = p.responseXML;
+ var d = request.responseXML;
var str = s.serializeToString(d);
dump("\nmade it in PUT\n" + str + "\n");
@@ -69,12 +73,12 @@
var s = new XMLSerializer();
str = s.serializeToString(x);
- p.onload = myfunc;
- p.open("PUT",puturl);
- p.setRequestHeader("Content-type", "text/xml");
- p.setRequestHeader("Host","localhost");
- p.setRequestHeader(typeheader, "PageTemplate");
- p.send(x);
+ request.onload = myfunc;
+ request.open("PUT",puturl);
+ request.setRequestHeader("Content-type", "text/xml");
+ request.setRequestHeader("Host","localhost");
+ request.setRequestHeader(typeheader, "PageTemplate");
+ request.send(x);
return;
}
=== Packages/Moztop/moztop/content/lib/sitesmanager.js 1.11 => 1.12 ===
--- Packages/Moztop/moztop/content/lib/sitesmanager.js:1.11 Sat Mar 22 22:05:25 2003
+++ Packages/Moztop/moztop/content/lib/sitesmanager.js Sun Mar 23 08:32:52 2003
@@ -158,6 +158,8 @@
// Create a new site and add it to the sites resource
var newsite = sitesds.getNode(rsdurl);
newsite.addTarget(this.titleprop, title);
+ newsite.addTarget(this.resourcetypeprop,
+ 'urn:moztop:resourcetypes:site');
sites.addChild(newsite);
// Save the changes
@@ -191,12 +193,6 @@
}
-SitesManager.prototype.removeSelectedSite = function() {
- /* Remove selected site from navigation tree */
- this.removeSite(this.getSelectedResource().getValue());
-}
-
-
SitesManager.prototype.openSelectedResource = function() {
/* This function "opens" the selected Tree resource. */
var rdf = this.getSelectedResource();
@@ -222,7 +218,7 @@
// Retrieving resource type
typeURN = rdf.getTarget(this.resourcetypeprop).getValue();
- type = this.getNode(typeURN);
+ type = this.getResource(typeURN);
// XXX: The type registry should really have an attribute for this.
typeViewerName = type.getTarget(this.styleidprop).getValue() + "viewer";
@@ -247,6 +243,34 @@
tabs.selectedItem = tab;
panels.selectedPanel = viewer;
}
+
+
+DataSourceManager.prototype.removeSelectedResource = function() {
+ /* This function deletes the selected Tree resource. */
+ resource = this.getSelectedResource();
+ type = resource.getTarget(this.resourcetypeprop).getValue();
+
+ if (type == 'urn:moztop:resourcetypes:site') {
+ return this.removeSite(resource.getValue());
+ }
+ if (type == 'urn:moztop:resourcetypes:configurations' ||
+ type == 'urn:moztop:resourcetypes:content' ||
+ type == 'urn:moztop:resourcetypes:packages' ||
+ type == 'urn:moztop:resourcetypes:views') {
+ type_title = this.getResource(type).getTarget(
+ this.titleprop).getValue();
+ alert('Objects of type ' + type_title + ' cannot be deleted.');
+ return true;
+ }
+
+ // Deleting item from server
+ DELETE(resource.getValue());
+
+ // Update RDF
+ resource.datasource.Refresh(0);
+
+}
+
/* Initialize the Sites Manager */