Display the owner and expiration time of a pad in the properties modal
This commit is contained in:
@@ -128,6 +128,38 @@ define([
|
||||
]);
|
||||
};
|
||||
|
||||
/**
|
||||
* tabs is an array containing objects
|
||||
* each object must have the following attributes:
|
||||
* - title: String
|
||||
* - content: DOMElement
|
||||
*/
|
||||
dialog.tabs = function (tabs) {
|
||||
var contents = [];
|
||||
var titles = [];
|
||||
tabs.forEach(function (tab) {
|
||||
if (!tab.content || !tab.title) { return; }
|
||||
var content = tab.content;
|
||||
var title = h('span.alertify-tabs-title', tab.title);
|
||||
$(title).click(function () {
|
||||
titles.forEach(function (t) { $(t).removeClass('alertify-tabs-active'); });
|
||||
contents.forEach(function (c) { $(c).removeClass('alertify-tabs-content-active'); });
|
||||
$(title).addClass('alertify-tabs-active');
|
||||
$(content).addClass('alertify-tabs-content-active');
|
||||
});
|
||||
titles.push(title);
|
||||
contents.push(content);
|
||||
});
|
||||
if (contents.length) {
|
||||
$(contents[0]).addClass('alertify-tabs-content-active');
|
||||
$(titles[0]).addClass('alertify-tabs-active');
|
||||
}
|
||||
return h('div.alertify-tabs', [
|
||||
h('div.alertify-tabs-titles', titles),
|
||||
h('div.alertify-tabs-contents', contents),
|
||||
]);
|
||||
};
|
||||
|
||||
UI.tokenField = function (target) {
|
||||
var t = {
|
||||
element: target || h('input'),
|
||||
|
||||
@@ -89,17 +89,50 @@ define([
|
||||
common.getPadAttribute('tags', waitFor(function (err, val) {
|
||||
data.tags = val;
|
||||
}));
|
||||
common.getPadAttribute('owners', waitFor(function (err, val) {
|
||||
data.owners = val;
|
||||
}));
|
||||
common.getPadAttribute('expire', waitFor(function (err, val) {
|
||||
data.expire = val;
|
||||
}));
|
||||
}).nThen(function () {
|
||||
cb(void 0, data);
|
||||
});
|
||||
};
|
||||
UIElements.getProperties = function (common, data, cb) {
|
||||
var getRightsProperties = function (common, data, cb) {
|
||||
var $d = $('<div>');
|
||||
$('<strong>').text(Messages.fc_prop).appendTo($d);
|
||||
if (!data) { return void cb(void 0, $d); }
|
||||
|
||||
$('<label>', {'for': 'cp-app-prop-owners'}).text(Messages.creation_owners)
|
||||
.appendTo($d);
|
||||
var owners = Messages.creation_noOwner;
|
||||
var edPublic = common.getMetadataMgr().getPrivateData().edPublic;
|
||||
if (data.owners && data.owners.length) {
|
||||
if (data.owners.indexOf(edPublic) !== -1) {
|
||||
owners = Messages.yourself;
|
||||
} else {
|
||||
owners = Messages.creation_ownedByOther;
|
||||
}
|
||||
}
|
||||
$d.append(UI.dialog.selectable(owners, {
|
||||
id: 'cp-app-prop-owners',
|
||||
}));
|
||||
|
||||
var expire = Messages.creation_expireFalse;
|
||||
if (data.expire && typeof (data.expire) === "number") {
|
||||
expire = new Date(data.expire).toLocaleString();
|
||||
}
|
||||
$('<label>', {'for': 'cp-app-prop-expire'}).text(Messages.creation_expiration)
|
||||
.appendTo($d);
|
||||
$d.append(UI.dialog.selectable(expire, {
|
||||
id: 'cp-app-prop-expire',
|
||||
}));
|
||||
cb(void 0, $d);
|
||||
};
|
||||
var getPadProperties = function (common, data, cb) {
|
||||
var $d = $('<div>');
|
||||
if (!data || !data.href) { return void cb(void 0, $d); }
|
||||
|
||||
$('<br>').appendTo($d);
|
||||
if (data.href) {
|
||||
$('<label>', {'for': 'cp-app-prop-link'}).text(Messages.editShare).appendTo($d);
|
||||
$d.append(UI.dialog.selectable(data.href, {
|
||||
@@ -162,6 +195,27 @@ define([
|
||||
cb(void 0, $d);
|
||||
}
|
||||
};
|
||||
UIElements.getProperties = function (common, data, cb) {
|
||||
var c1;
|
||||
var c2;
|
||||
NThen(function (waitFor) {
|
||||
getPadProperties(common, data, waitFor(function (e, c) {
|
||||
c1 = c[0];
|
||||
}));
|
||||
getRightsProperties(common, data, waitFor(function (e, c) {
|
||||
c2 = c[0];
|
||||
}));
|
||||
}).nThen(function () {
|
||||
var tabs = UI.dialog.tabs([{
|
||||
title: Messages.fc_prop,
|
||||
content: c1
|
||||
}, {
|
||||
title: Messages.creation_propertiesTitle,
|
||||
content: c2
|
||||
}]);
|
||||
cb (void 0, $(tabs));
|
||||
});
|
||||
};
|
||||
|
||||
UIElements.createButton = function (common, type, rightside, data, callback) {
|
||||
var AppConfig = common.getAppConfig();
|
||||
@@ -1261,6 +1315,8 @@ define([
|
||||
var metadataMgr = common.getMetadataMgr();
|
||||
var type = metadataMgr.getMetadataLazy().type;
|
||||
|
||||
// XXX check text for pad creation screen + translate it in French
|
||||
|
||||
var $body = $('body');
|
||||
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
|
||||
var $creation = $('<div>', { id: 'cp-creation' }).appendTo($creationContainer);
|
||||
@@ -1366,10 +1422,6 @@ define([
|
||||
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
|
||||
}
|
||||
|
||||
// XXX TODO remove these lines
|
||||
//ownedVal = undefined;
|
||||
//expire = undefined;
|
||||
|
||||
sframeChan.query("Q_CREATE_PAD", {
|
||||
owned: ownedVal,
|
||||
expire: expireVal,
|
||||
|
||||
@@ -362,6 +362,7 @@ define([
|
||||
if (!data.href) { return void cb({error:'NO_HREF'}); }
|
||||
var pad = makePad(data.href, data.title);
|
||||
if (data.owners) { pad.owners = data.owners; }
|
||||
if (data.expire) { pad.expire = data.expire; }
|
||||
store.userObject.pushData(pad, function (e, id) {
|
||||
if (e) { return void cb({error: "Error while adding a template:"+ e}); }
|
||||
var path = data.path || ['root'];
|
||||
@@ -527,6 +528,10 @@ define([
|
||||
if (Store.channel && Util.base64ToHex(h.channel) === Store.channel.wc.id) {
|
||||
owners = Store.channel.data.owners || undefined;
|
||||
}
|
||||
var expire;
|
||||
if (Store.channel && Util.base64ToHex(h.channel) === Store.channel.wc.id) {
|
||||
expire = +Store.channel.data.expire || undefined;
|
||||
}
|
||||
|
||||
var allPads = Util.find(store.proxy, ['drive', 'filesData']) || {};
|
||||
var isStronger;
|
||||
@@ -590,6 +595,7 @@ define([
|
||||
href: href,
|
||||
title: title,
|
||||
owners: owners,
|
||||
expire: expire,
|
||||
path: data.path || (store.data && store.data.initialPath)
|
||||
}, cb);
|
||||
return;
|
||||
|
||||
@@ -189,7 +189,6 @@ define([], function () {
|
||||
expire: expire,
|
||||
password: password
|
||||
};
|
||||
padData = cfg;
|
||||
var msg = ['GET_HISTORY', wc.id, cfg];
|
||||
// Add the validateKey if we are the channel creator and we have a validateKey
|
||||
if (hk) { network.sendto(hk, JSON.stringify(msg)); }
|
||||
|
||||
Reference in New Issue
Block a user