mirror of https://github.com/perkeep/perkeep.git
ui: Add support for setting camliAccess attr on permanodes.
The attribute can be set to "public" to share to everyone or deleted to keep the permanode private. Change-Id: I075dd7cc5fb6c3726083ae065282178dd7ae99a3
This commit is contained in:
parent
6118464cd4
commit
b1e1193ca6
|
@ -23,30 +23,40 @@ div.fileupload {
|
|||
|
||||
<form id="formTitle">
|
||||
<p>Title: <input type="text" id="inputTitle" size="30" value="(loading)" disabled="disabled" />
|
||||
<input type="submit" id="btnSave" value="Save" disabled="disabled" /></p>
|
||||
<input type="submit" id="btnSaveTitle" value="Save" disabled="disabled" /></p>
|
||||
</form>
|
||||
|
||||
<form id="formTags">
|
||||
<p>Tags: <span id="spanTags"></span> <input id="inputNewTag" /> <input type="submit" id="btnAddTag" value="Add Tag(s)" />
|
||||
</form>
|
||||
|
||||
<form id="formAccess">
|
||||
<p>Access:
|
||||
<select id="selectAccess" disabled="disabled">
|
||||
<option value="private">Private</option>
|
||||
<option value="public">Public</option>
|
||||
</select>
|
||||
<input type="submit" id="btnSaveAccess" value="Save" disabled="disabled" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<div id="content"></div>
|
||||
|
||||
<div id="members"></div>
|
||||
|
||||
<form id="formType">
|
||||
<p>Type:
|
||||
<select id='type'>
|
||||
<option value=''>(None / auto)</option>
|
||||
<option value='_other'>(Other)</option>
|
||||
<option value="file">File</option>
|
||||
<option value="collection">File Collection / Gallery</option>
|
||||
<option value="microblog">Microblog Post</option>
|
||||
<option value="blog">Blog Post</option>
|
||||
</select>
|
||||
</p>
|
||||
<select id='type'>
|
||||
<option value=''>(None / auto)</option>
|
||||
<option value='_other'>(Other)</option>
|
||||
<option value="file">File</option>
|
||||
<option value="collection">File Collection / Gallery</option>
|
||||
<option value="microblog">Microblog Post</option>
|
||||
<option value="blog">Blog Post</option>
|
||||
</select>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
<div id='dnd' style="border: 2px dashed black; min-height: 250px; display: block;">
|
||||
<form id="fileForm">
|
||||
<input type="file" id="fileInput" multiple="true" onchange="">
|
||||
|
|
|
@ -26,8 +26,8 @@ function handleFormTitleSubmit(e) {
|
|||
|
||||
var inputTitle = document.getElementById("inputTitle");
|
||||
inputTitle.disabled = "disabled";
|
||||
var btnSave = document.getElementById("btnSave");
|
||||
btnSave.disabled = "disabled";
|
||||
var btnSaveTitle = document.getElementById("btnSaveTitle");
|
||||
btnSaveTitle.disabled = "disabled";
|
||||
|
||||
var startTime = new Date();
|
||||
|
||||
|
@ -40,13 +40,13 @@ function handleFormTitleSubmit(e) {
|
|||
var elapsedMs = new Date().getTime() - startTime.getTime();
|
||||
setTimeout(function() {
|
||||
inputTitle.disabled = null;
|
||||
btnSave.disabled = null;
|
||||
btnSaveTitle.disabled = null;
|
||||
}, Math.max(250 - elapsedMs, 0));
|
||||
},
|
||||
fail: function(msg) {
|
||||
alert(msg);
|
||||
inputTitle.disabled = null;
|
||||
btnSave.disabled = null;
|
||||
btnSaveTitle.disabled = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ function handleFormTagsSubmit(e) {
|
|||
}
|
||||
};
|
||||
for (idx in tags) {
|
||||
var tag = tags[idx];
|
||||
var tag = tags[idx];
|
||||
camliNewAddAttributeClaim(
|
||||
getPermanodeParam(),
|
||||
"tag",
|
||||
|
@ -96,6 +96,44 @@ function handleFormTagsSubmit(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleFormAccessSubmit(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
var selectAccess = document.getElementById("selectAccess");
|
||||
selectAccess.disabled = "disabled";
|
||||
var btnSaveAccess = document.getElementById("btnSaveAccess");
|
||||
btnSaveAccess.disabled = "disabled";
|
||||
|
||||
var operation = camliNewDelAttributeClaim;
|
||||
var value = "";
|
||||
if (selectAccess.value != "private") {
|
||||
operation = camliNewSetAttributeClaim;
|
||||
value = selectAccess.value;
|
||||
}
|
||||
|
||||
var startTime = new Date();
|
||||
|
||||
operation(
|
||||
getPermanodeParam(),
|
||||
"camliAccess",
|
||||
value,
|
||||
{
|
||||
success: function() {
|
||||
var elapsedMs = new Date().getTime() - startTime.getTime();
|
||||
setTimeout(function() {
|
||||
selectAccess.disabled = null;
|
||||
btnSaveAccess.disabled = null;
|
||||
}, Math.max(250 - elapsedMs, 0));
|
||||
},
|
||||
fail: function(msg) {
|
||||
alert(msg);
|
||||
selectAccess.disabled = null;
|
||||
btnSaveAccess.disabled = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteTagFunc(tag, strikeEle, removeEle) {
|
||||
return function(e) {
|
||||
strikeEle.innerHTML = "<s>" + strikeEle.innerHTML + "</s>";
|
||||
|
@ -121,9 +159,8 @@ function onTypeChange(e) {
|
|||
if (sel.value == "collection" || sel.value == "") {
|
||||
dnd.style.display = "block";
|
||||
} else {
|
||||
dnd.style.display = "none";
|
||||
dnd.style.display = "none";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var lastFiles;
|
||||
|
@ -205,7 +242,7 @@ function onFileInputChange(e) {
|
|||
handleFiles(document.getElementById("fileInput").files);
|
||||
}
|
||||
|
||||
function setupFilesHandlers(e) {
|
||||
function setupFilesHandlers(e) {
|
||||
var dnd = document.getElementById("dnd");
|
||||
document.getElementById("fileForm").addEventListener("submit", onFileFormSubmit);
|
||||
document.getElementById("fileInput").addEventListener("change", onFileInputChange);
|
||||
|
@ -294,7 +331,7 @@ function onBlobDescribed(jres) {
|
|||
var tags = permanodeObject.attr.tag;
|
||||
for (idx in tags) {
|
||||
var tagSpan = document.createElement("span");
|
||||
|
||||
|
||||
if (idx > 0) {
|
||||
tagSpan.appendChild(document.createTextNode(", "));
|
||||
}
|
||||
|
@ -313,8 +350,16 @@ function onBlobDescribed(jres) {
|
|||
spanTags.appendChild(tagSpan);
|
||||
}
|
||||
|
||||
var btnSave = document.getElementById("btnSave");
|
||||
btnSave.disabled = null;
|
||||
var selectAccess = document.getElementById("selectAccess");
|
||||
var access = permanodeObject.attr.camliAccess;
|
||||
selectAccess.value = (access && access.length) ? access[0] : "private";
|
||||
selectAccess.disabled = null;
|
||||
|
||||
var btnSaveTitle = document.getElementById("btnSaveTitle");
|
||||
btnSaveTitle.disabled = null;
|
||||
|
||||
var btnSaveAccess = document.getElementById("btnSaveAccess");
|
||||
btnSaveAccess.disabled = null;
|
||||
}
|
||||
|
||||
function permanodePageOnLoad (e) {
|
||||
|
@ -328,7 +373,9 @@ function permanodePageOnLoad (e) {
|
|||
formTitle.addEventListener("submit", handleFormTitleSubmit);
|
||||
var formTags = document.getElementById("formTags");
|
||||
formTags.addEventListener("submit", handleFormTagsSubmit);
|
||||
|
||||
var formAccess = document.getElementById("formAccess");
|
||||
formAccess.addEventListener("submit", handleFormAccessSubmit);
|
||||
|
||||
var selectType = document.getElementById("type");
|
||||
selectType.addEventListener("change", onTypeChange);
|
||||
|
||||
|
|
Loading…
Reference in New Issue