Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow type change in ArtifactIndex (Closes #1681) #1682

Merged
merged 7 commits into from
May 11, 2020
9 changes: 4 additions & 5 deletions src/visualizers/panels/ArtifactIndex/ArtifactIndexControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ define([
};
this._widget.getConfigDialog = () => new ConfigDialog(this._client);

this._widget.onNameChange = (id, newName) => {
var name = this._client.getNode(id).getAttribute('name'),
msg = `Renamed "${name}" artifact to "${newName}"`;

this._widget.onAttributeChange = (id, attr, newValue) => {
const attrValue = this._client.getNode(id).getAttribute(attr),
msg = `Changed "${attr}'s" value from ${attrValue}" to "${newValue}"`;
umesh-timalsina marked this conversation as resolved.
Show resolved Hide resolved
this._client.startTransaction(msg);
this._client.setAttribute(id, 'name', newName);
this._client.setAttribute(id, attr, newValue);
this._client.completeTransaction();
};
};
Expand Down
32 changes: 19 additions & 13 deletions src/visualizers/widgets/ArtifactIndex/ArtifactIndexWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,9 @@ define([
event.stopPropagation();
event.preventDefault();
});
node.$name.on('dblclick', event => {
const name = $(event.target);
name.editInPlace({
css: {
'z-index': 1000
},
onChange: (oldVal, newVal) => {
if (newVal && newVal !== oldVal) {
this.onNameChange(desc.id, newVal);
}
}
});
});
node.$name.on('dblclick', {id : desc.id, attr: 'name'}, this.editInPlace.bind(this));
umesh-timalsina marked this conversation as resolved.
Show resolved Hide resolved

node.$type.on('dblclick', {id: desc.id, attr: 'type'}, this.editInPlace.bind(this));

node.$info.on('click', event => {
event.stopPropagation();
Expand Down Expand Up @@ -139,6 +129,22 @@ define([
}
};

ArtifactIndexWidget.prototype.editInPlace = function(event) {
const el = $(event.target);
const id = event.data.id;
const attr = event.data.attr;
el.editInPlace({
css: {
'z-index' : 1000
},
onChange: (oldVal, newVal) => {
if (newVal && newVal !== oldVal) {
this.onAttributeChange(id, attr, newVal);
}
}
});
};

/* * * * * * * * Visualizer event handlers * * * * * * * */


Expand Down
2 changes: 1 addition & 1 deletion src/visualizers/widgets/ArtifactIndex/ModelRow.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tr>
<td><span class="name"></span></td>
<td class="type"></td>
<td><span class="type"></span></td>
<td class="size"></td>
<td class="createdAt"></td>
<td class="actions">
Expand Down