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

Timepicker on the right #11980

Merged
merged 12 commits into from
Jun 9, 2017
2 changes: 1 addition & 1 deletion src/ui/public/angular-bootstrap/datepicker/day.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<table
class="kuiDatePicker"
class="kuiDatePicker fullWidth"
role="grid"
aria-labelledby="{{uniqueId}}-title"
aria-activedescendant="{{activeDateId}}"
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/angular-bootstrap/datepicker/month.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<table
class="kuiDatePicker"
class="kuiDatePicker fullWidth"
role="grid"
aria-labelledby="{{uniqueId}}-title"
aria-activedescendant="{{activeDateId}}"
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/angular-bootstrap/datepicker/year.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<table
class="kuiDatePicker"
class="kuiDatePicker fullWidth"
role="grid"
aria-labelledby="{{uniqueId}}-title"
aria-activedescendant="{{activeDateId}}"
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/directives/__tests__/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ describe('timepicker directive', function () {

it('has a preview of the "from" input', function () {
const preview = $elem.find('.kbn-timepicker-section span[ng-show="relative.from.preview"]');
expect(preview.text()).to.be(moment().subtract(15, 'minutes').format($scope.format));
expect(preview.text().trim()).to.be(moment().subtract(15, 'minutes').format($scope.format));
});

it('has a disabled "to" field that contains "Now"', function () {
expect($elem.find('.kbn-timepicker-section span[ng-show="relative.to.preview"]').text()).to.be('Now');
expect($elem.find('.kbn-timepicker-section span[ng-show="relative.to.preview"]').text().trim()).to.be('Now');
});

it('has a submit handler', function () {
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/timepicker/absolute_panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './kbn_timepicker_absolute_panel';
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<form name="absoluteTime" ng-submit="applyAbsolute()">
<div class="kbn-timepicker-body">
<div class="kbn-timepicker-section kbn-timepicker-body-column">
<div class="kuiLocalDropdownHeader kbn-timepicker-form-header">
<label class="kuiLocalDropdownHeader__label">
From
</label>

<div class="kuiLocalDropdownHeader__actions">
<a
class="kuiLocalDropdownHeader__action"
ng-click="setToNow({key:'from'})"
kbn-accessible-click
>
Set To Now
</a>
</div>
</div>

<input
type="text"
required
class="kuiTextInput fullWidth"
input-datetime="{{format}}"
ng-model="absolute.from"
>
<div ng-show="!absolute.from"><em>Invalid Date</em></div>

<div>
<datepicker ng-model="pickFromDate" ng-model-options="{ getterSetter: true }" max-date="absolute.to" show-weeks="false"></datepicker>
</div>
</div>

<div class="kbn-timepicker-section kbn-timepicker-body-column">
<div class="kuiLocalDropdownHeader kbn-timepicker-form-header">
<label class="kuiLocalDropdownHeader__label">
To
</label>

<div class="kuiLocalDropdownHeader__actions">
<a
class="kuiLocalDropdownHeader__action"
ng-click="setToNow({key:'to'})"
kbn-accessible-click
>
Set To Now
</a>
</div>
</div>

<span ng-show="!absolute.to"><em>Invalid Date</em></span>
<input
type="text"
required
class="kuiTextInput fullWidth"
input-datetime="{{format}}"
ng-model="absolute.to"
>

<div>
<datepicker ng-model="pickToDate" ng-model-options="{ getterSetter: true }" min-date="absolute.from" show-weeks="false"></datepicker>
</div>
</div>
</div>

<div class="kbn-timepicker-actions">
<button
data-test-subj="timepickerGoButton"
class="kuiButton kuiButton--primary kbn-timepicker-submit-button"
ng-disabled="absolute.from > absolute.to || !absolute.from || !absolute.to"
type="submit"
>
Go
</button>
<span class="small" ng-show="absolute.from > absolute.to"><strong>From</strong> must occur before <strong>To</strong></span>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import template from './kbn_timepicker_absolute_panel.html';
import { uiModules } from 'ui/modules';

const module = uiModules.get('ui/timepicker');

module.directive('kbnTimepickerAbsolutePanel', function () {
return {
restrict: 'E',
replace: true,
scope: {
absolute: '=',
applyAbsolute: '&',
format: '=',
pickFromDate: '=',
pickToDate: '=',
setToNow: '&'
},
template,
controller: function () {
}
};
});
1 change: 1 addition & 0 deletions src/ui/public/timepicker/quick_panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './kbn_timepicker_quick_panel';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="kbn-timepicker-body">
<div ng-repeat="list in quickLists" class="kbn-timepicker-section">
<ul class="list-unstyled">
<li ng-repeat="option in list">
<a
ng-click="setQuick({from: option.from, to: option.to})"
ng-bind="::option.display"
kbn-accessible-click
></a>
</li>
</ul>
</div>
</div>
19 changes: 19 additions & 0 deletions src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import _ from 'lodash';
import template from './kbn_timepicker_quick_panel.html';
import { uiModules } from 'ui/modules';

const module = uiModules.get('ui/timepicker');

module.directive('kbnTimepickerQuickPanel', function (quickRanges) {
return {
restrict: 'E',
replace: true,
scope: {
setQuick: '&'
},
template,
controller: function ($scope) {
$scope.quickLists = _(quickRanges).groupBy('section').values().value();
}
};
});
1 change: 1 addition & 0 deletions src/ui/public/timepicker/relative_panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './kbn_timepicker_relative_panel';
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<form role="form" ng-submit="applyRelative()" class="form-inline" name="relativeTime">
<div class="kbn-timepicker-body kuiVerticalRhythm">
<div class="kbn-timepicker-section kbn-timepicker-body-column">
<div class="kuiLocalDropdownHeader kbn-timepicker-form-header">
<label class="kuiLocalDropdownHeader__label">
From
</label>

<div class="kuiLocalDropdownHeader__actions">
<a
class="kuiLocalDropdownHeader__action"
ng-click="setRelativeToNow({key:'from'})"
kbn-accessible-click
>
Set To Now
</a>
</div>
</div>

<div class="kuiLocalDropdownFormNote kuiVerticalRhythmSmall">
<span ng-show="relative.from.preview">
{{relative.from.preview}}
</span>
<span ng-hide="relative.from.preview">
<em>Invalid Expression</em>
</span>
</div>

<div class="kuiFieldGroup kuiVerticalRhythmSmall">
<div class="kuiFieldGroupSection kuiFieldGroupSection--wide">
<input
required
ng-model="relative.from.count"
ng-change="formatRelative({key:'from'})"
greater-than="-1"
min="0"
type="number"
ng-class="{ 'kuiTextInput-isInvalid' : checkRelative() }"
class="kuiTextInput fullWidth"
>
</div>

<div class="kuiFieldGroupSection">
<select
ng-model="relative.from.unit"
ng-options="opt.value as opt.text for opt in relativeOptions"
ng-change="formatRelative({key:'from'})"
ng-class="{ 'kuiSelect-isInvalid': checkRelative() }"
class="kuiSelect fullWidth"
>
</select>
</div>
</div>

<div class="kuiVerticalRhythmSmall">
<label class="kuiCheckBoxLabel">
<input
class="kuiCheckBox"
type="checkbox"
ng-model="relative.from.round"
ng-checked="relative.from.round"
ng-change="formatRelative({key:'from'})"
>
<span class="kuiCheckBoxLabel__text">
round to the {{units[relative.from.unit.substring(0,1)]}}
</span>
</label>
<div
ng-class="{ 'kbn-timepicker-error': checkRelative() }"
ng-show="checkRelative()">
<strong>From</strong> must occur before <strong>To</strong>
</div>
</div>
</div>

<div class="kbn-timepicker-section kbn-timepicker-body-column">
<div class="kuiLocalDropdownHeader kbn-timepicker-form-header">
<label class="kuiLocalDropdownHeader__label">
To
</label>

<div class="kuiLocalDropdownHeader__actions">
<a
class="kuiLocalDropdownHeader__action"
ng-click="setRelativeToNow({key:'to'})"
kbn-accessible-click
>
Set To Now
</a>
</div>
</div>

<div class="kuiLocalDropdownFormNote kuiVerticalRhythmSmall">
<span ng-show="relative.to.preview">
{{relative.to.preview}}
</span>
<span ng-hide="relative.to.preview">
<em>Invalid Expression</em>
</span>
</div>

<div class="kuiFieldGroup kuiVerticalRhythmSmall">
<div class="kuiFieldGroupSection kuiFieldGroupSection--wide">
<input
required
ng-model="relative.to.count"
ng-change="formatRelative({key:'to'})"
greater-than="-1"
min="0"
type="number"
ng-class="{ 'kuiTextInput-isInvalid': checkRelative() }"
class="kuiTextInput fullWidth"
>
</div>

<div class="kuiFieldGroupSection">
<select
ng-model="relative.to.unit"
ng-options="opt.value as opt.text for opt in relativeOptions"
ng-change="formatRelative({key:'to'})"
ng-class="{ 'kuiSelect-isInvalid': checkRelative() }"
class="kuiSelect fullWidth"
>
</select>
</div>
</div>

<div class="kuiVerticalRhythmSmall">
<label class="kuiCheckBoxLabel">
<input
class="kuiCheckBox"
type="checkbox"
ng-model="relative.to.round"
ng-checked="relative.to.round"
ng-change="formatRelative({key:'to'})"
>
<span class="kuiCheckBoxLabel__text">
round to the {{units[relative.to.unit.substring(0,1)]}}
</span>
</label>
</div>
</div>
</div>

<div class="kbn-timepicker-actions kuiVerticalRhythm">
<button
data-test-subj="timepickerGoButton"
type="submit"
class="kuiButton kuiButton--primary kbn-timepicker-submit-button"
ng-disabled="!(relative.from.preview && relative.to.preview) || checkRelative()"
>
Go
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import template from './kbn_timepicker_relative_panel.html';
import { uiModules } from 'ui/modules';

const module = uiModules.get('ui/timepicker');

module.directive('kbnTimepickerRelativePanel', function () {
return {
restrict: 'E',
replace: true,
scope: {
applyRelative: '&',
checkRelative: '&',
formatRelative: '&',
relative: '=',
relativeOptions: '=',
setRelativeToNow: '&',
units: '='
},
template,
controller: function () {
}
};
});
Loading