Просмотр исходного кода

timerange: new quick ranges, month and year so far

The new time ranges can also be used for time range overrides in the
override relative time field. E.g. now/M or now/y.
Daniel Lee 8 лет назад
Родитель
Сommit
540ee35393
2 измененных файлов с 13 добавлено и 1 удалено
  1. 3 1
      public/app/core/utils/rangeutil.ts
  2. 10 0
      public/test/core/utils/rangeutil_specs.ts

+ 3 - 1
public/app/core/utils/rangeutil.ts

@@ -18,9 +18,11 @@ var rangeOptions = [
   { from: 'now/d',    to: 'now/d',    display: 'Today',                 section: 2 },
   { from: 'now/d',    to: 'now/d',    display: 'Today',                 section: 2 },
   { from: 'now/d',    to: 'now',      display: 'Today so far',          section: 2 },
   { from: 'now/d',    to: 'now',      display: 'Today so far',          section: 2 },
   { from: 'now/w',    to: 'now/w',    display: 'This week',             section: 2 },
   { from: 'now/w',    to: 'now/w',    display: 'This week',             section: 2 },
-  { from: 'now/w',    to: 'now',      display: 'This week so far',           section: 2 },
+  { from: 'now/w',    to: 'now',      display: 'This week so far',      section: 2 },
   { from: 'now/M',    to: 'now/M',    display: 'This month',            section: 2 },
   { from: 'now/M',    to: 'now/M',    display: 'This month',            section: 2 },
+  { from: 'now/M',    to: 'now',      display: 'This month so far',     section: 2 },
   { from: 'now/y',    to: 'now/y',    display: 'This year',             section: 2 },
   { from: 'now/y',    to: 'now/y',    display: 'This year',             section: 2 },
+  { from: 'now/y',    to: 'now',      display: 'This year so far',      section: 2 },
 
 
   { from: 'now-1d/d', to: 'now-1d/d', display: 'Yesterday',             section: 1 },
   { from: 'now-1d/d', to: 'now-1d/d', display: 'Yesterday',             section: 1 },
   { from: 'now-2d/d', to: 'now-2d/d', display: 'Day before yesterday',  section: 1 },
   { from: 'now-2d/d', to: 'now-2d/d', display: 'Day before yesterday',  section: 1 },

+ 10 - 0
public/test/core/utils/rangeutil_specs.ts

@@ -47,6 +47,16 @@ describe("rangeUtil", () => {
       var info = rangeUtil.describeTextRange('now/w');
       var info = rangeUtil.describeTextRange('now/w');
       expect(info.display).to.be('This week so far');
       expect(info.display).to.be('This week so far');
     });
     });
+
+    it('should handle now/M', () => {
+      var info = rangeUtil.describeTextRange('now/M');
+      expect(info.display).to.be('This month so far');
+    });
+
+    it('should handle now/y', () => {
+      var info = rangeUtil.describeTextRange('now/y');
+      expect(info.display).to.be('This year so far');
+    });
   });
   });
 
 
   describe("Can get date range described", () => {
   describe("Can get date range described", () => {