add tags from drive

pull/1/head
ansuz 7 years ago
parent 1f35798194
commit d85db64939

@ -28,6 +28,20 @@ define([
* - createDropdown * - createDropdown
*/ */
UI.updateTags = function (common, href) {
var sframeChan = common.getSframeChannel();
sframeChan.query('Q_TAGS_GET', href || null, function (err, res) {
if (err || res.error) { return void console.error(err || res.error); }
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
if (!Array.isArray(tags)) { return; }
sframeChan.event('EV_TAGS_SET', {
tags: tags,
href: href,
});
});
});
};
UI.createButton = function (common, type, rightside, data, callback) { UI.createButton = function (common, type, rightside, data, callback) {
var AppConfig = common.getAppConfig(); var AppConfig = common.getAppConfig();
var button; var button;
@ -202,16 +216,7 @@ define([
title: Messages.tags_title, title: Messages.tags_title,
}) })
.click(common.prepareFeedback(type)) .click(common.prepareFeedback(type))
.click(function () { .click(function () { UI.updateTags(null); });
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
if (err || res.error) { return void console.error(err || res.error); }
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
if (!Array.isArray(tags)) { return; }
console.error(tags);
sframeChan.event('EV_TAGS_SET', tags);
});
});
});
break; break;
default: default:
button = $('<button>', { button = $('<button>', {

@ -401,7 +401,7 @@ define([
}); });
sframeChan.on('Q_TAGS_GET', function (data, cb) { sframeChan.on('Q_TAGS_GET', function (data, cb) {
Cryptpad.getPadTags(null, function (err, data) { Cryptpad.getPadTags(data, function (err, data) {
cb({ cb({
error: err, error: err,
data: data data: data
@ -410,8 +410,7 @@ define([
}); });
sframeChan.on('EV_TAGS_SET', function (data) { sframeChan.on('EV_TAGS_SET', function (data) {
console.log(data); Cryptpad.resetTags(data.href, data.tags);
Cryptpad.resetTags(null, data);
}); });
sframeChan.on('Q_PIN_GET_USAGE', function (data, cb) { sframeChan.on('Q_PIN_GET_USAGE', function (data, cb) {

@ -78,6 +78,7 @@ define([
funcs.displayAvatar = callWithCommon(UI.displayAvatar); funcs.displayAvatar = callWithCommon(UI.displayAvatar);
funcs.createButton = callWithCommon(UI.createButton); funcs.createButton = callWithCommon(UI.createButton);
funcs.createUsageBar = callWithCommon(UI.createUsageBar); funcs.createUsageBar = callWithCommon(UI.createUsageBar);
funcs.updateTags = callWithCommon(UI.updateTags);
// History // History
funcs.getHistory = callWithCommon(History.create); funcs.getHistory = callWithCommon(History.create);

@ -6,11 +6,13 @@
@import (once) '../../customize/src/less2/include/leftside-menu.less'; @import (once) '../../customize/src/less2/include/leftside-menu.less';
@import (once) "../../customize/src/less2/include/tools.less"; @import (once) "../../customize/src/less2/include/tools.less";
@import (once) "../../customize/src/less2/include/limit-bar.less"; @import (once) "../../customize/src/less2/include/limit-bar.less";
@import (once) "../../customize/src/less2/include/tokenfield.less";
.toolbar_main(); .toolbar_main();
.fileupload_main(); .fileupload_main();
.alertify_main(); .alertify_main();
.limit-bar_main(); .limit-bar_main();
.tokenfield_main();
@drive_hover: #eee; @drive_hover: #eee;
@drive_hover-light: lighten(@drive_hover, 20%); @drive_hover-light: lighten(@drive_hover, 20%);

@ -25,6 +25,7 @@
<li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete cp-app-drive-context-editable dropdown-item" data-localization="fc_delete">Delete</a></li> <li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete cp-app-drive-context-editable dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-folder" class="cp-app-drive-context-newfolder cp-app-drive-context-editable dropdown-item" data-localization="fc_newfolder">New folder</a></li> <li><a tabindex="-1" data-icon="fa-folder" class="cp-app-drive-context-newfolder cp-app-drive-context-editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li> <li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li>
<li><a tabindex="-1" data-icon="fa-hashtag" class="cp-app-drive-context-hashtag dropdown-item" data-localization="fc_hashtag">Tags</a></li>
</ul> </ul>
</div> </div>
<div id="cp-app-drive-context-content" class="cp-app-drive-context dropdown cp-unselectable"> <div id="cp-app-drive-context-content" class="cp-app-drive-context dropdown cp-unselectable">
@ -43,6 +44,7 @@
<li><a tabindex="-1" data-icon="fa-eye" class="cp-app-drive-context-openro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li> <li><a tabindex="-1" data-icon="fa-eye" class="cp-app-drive-context-openro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li>
<li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete dropdown-item" data-localization="fc_delete">Delete</a></li> <li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li> <li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li>
<li><a tabindex="-1" data-icon="fa-hashtag" class="cp-app-drive-context-hashtag dropdown-item" data-localization="fc_hashtag">Tags</a></li>
</ul> </ul>
</div> </div>
<div id="cp-app-drive-context-trashtree" class="cp-app-drive-context dropdown cp-unselectable"> <div id="cp-app-drive-context-trashtree" class="cp-app-drive-context dropdown cp-unselectable">

@ -663,6 +663,7 @@ define([
hasFolder = true; hasFolder = true;
hide.push($menu.find('a.cp-app-drive-context-openro')); hide.push($menu.find('a.cp-app-drive-context-openro'));
hide.push($menu.find('a.cp-app-drive-context-properties')); hide.push($menu.find('a.cp-app-drive-context-properties'));
hide.push($menu.find('a.cp-app-drive-context-hashtag'));
} }
// If we're in the trash, hide restore and properties for non-root elements // If we're in the trash, hide restore and properties for non-root elements
if ($menu.find('a.cp-app-drive-context-restore').length && path && path.length > 4) { if ($menu.find('a.cp-app-drive-context-restore').length && path && path.length > 4) {
@ -2567,6 +2568,14 @@ define([
Cryptpad.alert($prop[0], undefined, true); Cryptpad.alert($prop[0], undefined, true);
}); });
} }
else if ($(this).hasClass("cp-app-drive-context-hashtag")) {
if (paths.length !== 1) { return; }
var el = filesOp.find(paths[0].path);
var data = filesOp.getFileData(el);
if (!data) { return void console.error("Expected to find a file"); }
var href = data.href;
common.updateTags(href);
}
APP.hideMenu(); APP.hideMenu();
}); });
@ -2618,6 +2627,14 @@ define([
Cryptpad.alert($prop[0], undefined, true); Cryptpad.alert($prop[0], undefined, true);
}); });
} }
else if ($(this).hasClass("cp-app-drive-context-hashtag")) {
if (paths.length !== 1) { return; }
var el = filesOp.find(paths[0].path);
var data = filesOp.getFileData(el);
if (!data) { return void console.error("Expected to find a file"); }
var href = data.href;
common.updateTags(href);
}
APP.hideMenu(); APP.hideMenu();
}); });

Loading…
Cancel
Save