Commit 1c155f20 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

WorkspaceAddDialog: allow to select the workspace color (with a random default color)

parent f63d97da
......@@ -34,6 +34,11 @@
@keyup.13="action"
>
</div>
<vs-colorpicker :value.sync="wsColor">
<span class="input-group-addon">
color
</span>
</vs-colorpicker>
<div v-show="moreOpts">
<h4>Optional</h4>
<div class="input-group">
......
define([
"jquery",
"vispa/common/dialog",
"vispa/common/color",
"vispa/workspace",
"vispa/vue/colorpicker",
"text!../html/workspaceAddBody.html",
"text!../html/workspaceAddFooter.html",
], function(
$,
Dialog,
Color,
Workspace,
VueColorPicker,
tBody,
tFooter
) {
......@@ -17,6 +21,11 @@ define([
var userConf = vispa.args.user;
if (!userConf.addWorkspaces) return;
var color = new Color();
while(color.value.s < 0.5 || color.value.v > 1.0)
color = new Color(Color.getRandomName());
color = color.toString("alias");
return new Dialog({
data: {
moreOpts : !!(defaults.command || defaults.keyUsed),
......@@ -26,6 +35,7 @@ define([
wsHost : defaults.host || "",
wsUser : defaults.login || userConf.name || "",
wsCommand : defaults.command || "",
wsColor : defaults.color || color,
wsKey : "", // dont use the truncated key
containerClass: "workspace-add-dialog",
title : "Add a workspace",
......@@ -71,6 +81,7 @@ define([
return;
}
self.close();
ws.color = self.wsColor;
ws.connect();
});
return true;
......@@ -85,6 +96,9 @@ define([
body : tBody.trim(),
footerLeft: tFooter.trim(),
},
components: {
"vs-colorpicker": VueColorPicker,
},
appendTo: appendTo || this.$messageContainer && this.$messageContainer[0],
});
};
......
......@@ -26,5 +26,12 @@ define([
* :param Number val.a: HSBA alpha.
* :param Object predefinedColors: Additional named color aliases.
*/
return JClass._convert($.colorpicker.Color);
var Color = JClass._convert($.colorpicker.Color);
var colorNames = Object.keys(new Color().colors);
Color.getRandomName = function () {
return colorNames[Math.floor(Math.random()*colorNames.length)];
};
return Color;
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment