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

Edit-in-place component bugs #3049

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client/app/components/dynamic-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { find, filter, map, each } from 'lodash';
import template from './dynamic-table.html';
import './dynamic-table.less';

function isNullOrUndefined(v) {
return (v === null) || (v === undefined);
}

function filterRows(rows, searchTerm, columns) {
if ((searchTerm === '') || (columns.length === 0) || (rows.length === 0)) {
return rows;
Expand Down Expand Up @@ -34,11 +38,11 @@ function sortRows(rows, orderBy) {
for (let i = 0; i < orderBy.length; i += 1) {
va = a[orderBy[i].name];
vb = b[orderBy[i].name];
if (va == undefined || (va < vb)) {
if (isNullOrUndefined(va) || (va < vb)) {
// if a < b - we should return -1, but take in account direction
return orderBy[i].direction * -1;
}
if ((va > vb) || vb == undefined) {
if ((va > vb) || isNullOrUndefined(vb)) {
// if a > b - we should return 1, but take in account direction
return orderBy[i].direction * 1;
}
Expand Down
6 changes: 4 additions & 2 deletions client/app/components/groups/group-name.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function controller($window, $location, toastr, currentUser) {
this.canEdit = () => currentUser.isAdmin && this.group.type !== 'builtin';

this.saveName = () => {
this.saveName = (name) => {
this.group.name = name;
this.group.$save();
};

Expand All @@ -23,7 +24,8 @@ export default function init(ngModule) {
transclude: true,
template: `
<h2 class="m-t-0">
<edit-in-place class="edit-in-place" editable="$ctrl.canEdit()" on-done="$ctrl.saveName" ignore-blanks="'true'" value="$ctrl.group.name"></edit-in-place>&nbsp;
<edit-in-place class="edit-in-place" is-editable="$ctrl.canEdit()" on-done="$ctrl.saveName"
ignore-blanks="true" value="$ctrl.group.name" editor="'input'"></edit-in-place>&nbsp;
<button class="btn btn-xs btn-danger" ng-if="$ctrl.canEdit()" ng-click="$ctrl.deleteGroup()">Delete this group</button>
</h2>
`,
Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/dashboards/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="page-title col-xs-8 col-sm-7 col-lg-7 p-l-0">
<favorites-control item="$ctrl.dashboard"></favorites-control>
<h3>
<edit-in-place class="edit-in-place" editable="$ctrl.layoutEditing" on-done="$ctrl.saveName" ignore-blanks="true" value="$ctrl.dashboard.name" editor="'input'"></edit-in-place>
<edit-in-place class="edit-in-place" is-editable="$ctrl.layoutEditing" on-done="$ctrl.saveName" ignore-blanks="true" value="$ctrl.dashboard.name" editor="'input'"></edit-in-place>
</h3>
<span class="label label-default" ng-if="$ctrl.dashboard.is_draft && !$ctrl.dashboard.is_archived">Unpublished</span>
<span class="label label-warning" ng-if="$ctrl.dashboard.is_archived" uib-popover="This dashboard is archived and and won't appear in the dashboards list or search results." popover-placement="right" popover-trigger="'mouseenter'">Archived</span>
Expand Down
4 changes: 2 additions & 2 deletions client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="d-flex flex-nowrap align-items-center">
<favorites-control ng-if="!query.isNew()" item="query"></favorites-control>
<h3>
<edit-in-place editable="canEdit" on-done="saveName" ignore-blanks="true" value="query.name" editor="'input'"></edit-in-place>
<edit-in-place is-editable="canEdit" on-done="saveName" ignore-blanks="true" value="query.name" editor="'input'"></edit-in-place>
</h3>

<span class="flex-fill">&nbsp;</span>
Expand Down Expand Up @@ -94,7 +94,7 @@ <h3>
<div ng-if="!sourceMode" style="flex-grow: 1;">&nbsp;</div>

<div class="query-metadata query-metadata--description" ng-if="!query.isNew()">
<edit-in-place editable="canEdit" on-done="saveDescription" editor="'textarea'" placeholder="'Add description'" ignore-blanks='false'
<edit-in-place is-editable="canEdit" on-done="saveDescription" editor="'textarea'" placeholder="'Add description'" ignore-blanks='false'
value="query.description" markdown="true">
</edit-in-place>
</div>
Expand Down