Browse Source

Pull request #3412: 无jira refact:widget搞完了

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '12a77ed9bcd9e484f3d8c0578e3582122b170cdb':
  无jira refact:多了个import
  无jira refact:widget搞完了
es6
treecat-罗群 2 years ago
parent
commit
84520732a9
  1. 8
      src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
  2. 37
      src/component/form/form.field.js
  3. 13
      src/component/form/form.js
  4. 2
      src/widget/date/calendar/picker.date.js
  5. 4
      src/widget/date/calendar/picker.year.js
  6. 8
      src/widget/datetimepane/card.static.datetimepane.js
  7. 20
      src/widget/dynamicdate/dynamicdate.combo.js
  8. 18
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  9. 2
      src/widget/multilayerdownlist/combo.downlist.js
  10. 3
      src/widget/multilayersingletree/multilayersingletree.leveltree.js
  11. 6
      src/widget/multitree/check/multi.tree.check.pane.js
  12. 87
      src/widget/multitree/multi.tree.insert.combo.js
  13. 91
      src/widget/multitree/multi.tree.list.combo.js
  14. 10
      src/widget/multitree/multi.tree.popup.js
  15. 17
      src/widget/multitree/trigger/multi.tree.button.checkselected.js
  16. 38
      src/widget/multitree/trigger/multi.tree.search.insert.pane.js
  17. 4
      src/widget/multitree/trigger/multi.tree.search.pane.js
  18. 19
      src/widget/multitree/trigger/searcher.list.multi.tree.js
  19. 29
      src/widget/multitree/trigger/searcher.multi.tree.js
  20. 60
      src/widget/numbereditor/number.editor.js
  21. 127
      src/widget/numberinterval/numberinterval.js
  22. 62
      src/widget/numberinterval/singleeditor/single.editor.js
  23. 7
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
  24. 15
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
  25. 2
      src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
  26. 7
      src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
  27. 12
      src/widget/selecttree/selecttree.combo.js
  28. 10
      src/widget/selecttree/selecttree.expander.js
  29. 17
      src/widget/selecttree/selecttree.popup.js
  30. 28
      src/widget/singleselect/search/singleselect.search.loader.js
  31. 14
      src/widget/singleselect/search/singleselect.search.pane.insert.js
  32. 2
      src/widget/singleselect/search/singleselect.search.pane.js
  33. 48
      src/widget/singleselect/singleselect.combo.js
  34. 44
      src/widget/singleselect/singleselect.insert.combo.js
  35. 6
      src/widget/singleselect/singleselect.list.js
  36. 26
      src/widget/singleselect/singleselect.loader.js
  37. 3
      src/widget/singleselect/singleselect.popup.view.js
  38. 19
      src/widget/singleselect/singleselectlist.insert.js
  39. 12
      src/widget/singleselect/trigger/editor.singleselect.js
  40. 11
      src/widget/singleselect/trigger/searcher.singleselect.js
  41. 2
      src/widget/singleslider/button/iconbutton.slider.js
  42. 60
      src/widget/singleslider/singleslider.js
  43. 35
      src/widget/singleslider/singleslider.label.js
  44. 35
      src/widget/singleslider/singleslider.normal.js
  45. 9
      src/widget/singletree/singletree.combo.js
  46. 9
      src/widget/singletree/singletree.popup.js
  47. 10
      src/widget/singletree/singletree.trigger.js
  48. 8
      src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
  49. 69
      src/widget/time/datetime.popup.js
  50. 100
      src/widget/time/time.combo.js
  51. 99
      src/widget/time/time.trigger.js
  52. 63
      src/widget/timeinterval/dateinterval.js
  53. 75
      src/widget/timeinterval/timeinterval.js
  54. 49
      src/widget/timeinterval/timeperiods.js
  55. 35
      src/widget/year/card.dynamic.year.js
  56. 30
      src/widget/year/card.year.js
  57. 44
      src/widget/year/combo.year.js
  58. 106
      src/widget/year/popup.year.js
  59. 40
      src/widget/year/trigger.year.js
  60. 30
      src/widget/yearinterval/yearinterval.js
  61. 42
      src/widget/yearmonth/card.dynamic.yearmonth.js
  62. 20
      src/widget/yearmonth/card.static.yearmonth.js
  63. 35
      src/widget/yearmonth/combo.yearmonth.js
  64. 79
      src/widget/yearmonth/popup.yearmonth.js
  65. 44
      src/widget/yearmonth/trigger.yearmonth.js
  66. 19
      src/widget/yearmonthinterval/yearmonthinterval.js
  67. 35
      src/widget/yearquarter/combo.yearquarter.js

8
src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js

@ -1,5 +1,5 @@
import { shortcut, Widget, Selection, each, contains } from "@/core";
import { SearchMultiTextValueCombo } from "@/widget";
import { shortcut, Widget, Selection, each, contains } from "@/core";
@shortcut()
export class AllValueMultiTextValueCombo extends Widget {
@ -15,7 +15,7 @@ export class AllValueMultiTextValueCombo extends Widget {
const value = this._digestValue(o.value);
return {
type: "bi.search_multi_text_value_combo",
type: SearchMultiTextValueCombo.xtype,
simple: o.simple,
text: o.text,
height: o.height,
@ -27,12 +27,12 @@ export class AllValueMultiTextValueCombo extends Widget {
listeners: [
{
eventName: SearchMultiTextValueCombo.EVENT_CONFIRM,
action () {
action() {
self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM);
},
}
],
ref () {
ref() {
self.combo = this;
},
};

37
src/component/form/form.field.js

@ -1,5 +1,5 @@
import { shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
import { AbsoluteLayout, VerticalAdaptLayout, shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
import { Label } from "@/base";
@shortcut()
export class FormField extends Widget {
@ -11,21 +11,21 @@ export class FormField extends Widget {
el: {},
headerCls: "",
labelAlign: "right", // 文字默认右对齐
validate () {
validate() {
return true;
}, // 默认返回true
}
};
render () {
render() {
const self = this,
o = this.options;
const field = {
type: "bi.absolute",
type: AbsoluteLayout.xtype,
items: [
{
el: extend({}, o.el, {
ref (_ref) {
ref(_ref) {
self.field = _ref;
o.el.ref && o.el.ref.call(this, _ref);
},
@ -33,13 +33,13 @@ export class FormField extends Widget {
listeners: concat(o.el.listeners, [
{
eventName: "EVENT_CHANGE",
action () {
action() {
self.fireEvent("EVENT_CHANGE");
},
},
{
eventName: "EVENT_CONFIRM",
action () {
action() {
self.fireEvent("EVENT_CONFIRM");
},
}
@ -52,9 +52,9 @@ export class FormField extends Widget {
},
{
el: {
type: "bi.label",
type: Label.xtype,
cls: "error-tip bi-error",
ref (_ref) {
ref(_ref) {
self.error = _ref;
},
invisible: true,
@ -68,14 +68,14 @@ export class FormField extends Widget {
};
return {
type: "bi.vertical_adapt",
type: VerticalAdaptLayout.xtype,
columnSize: ["auto", "fill"],
verticalAlign: VerticalAlign.Stretch,
items: isKey(o.label)
? [
{
el: {
type: "bi.label",
type: Label.xtype,
textAlign: o.labelAlign,
text: o.label,
width: o.labelWidth,
@ -89,23 +89,20 @@ export class FormField extends Widget {
};
}
getValue () {
getValue() {
return this.field.getValue();
}
validate () {
validate() {
const isValid = this.validateWithNoTip();
!isValid &&
this.error.setText(
this.options.tip(this.field.getValue(), this.field)
);
!isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field));
this.error.setVisible(!isValid);
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error");
return isValid;
}
validateWithNoTip () {
validateWithNoTip() {
return this.options.validate(this.field.getValue(), this.field);
}
}

13
src/component/form/form.js

@ -1,4 +1,5 @@
import { shortcut, Widget, map, some, each } from "@/core";
import { VerticalLayout, shortcut, Widget, map, some, each } from "@/core";
import { FormField } from "./form.field";
import { ButtonGroup } from "@/base";
@shortcut()
@ -8,7 +9,7 @@ export class Form extends Widget {
props = {
baseCls: "bi-form",
labelAlign: "right",
layout: { type: "bi.vertical", vgap: 20 },
layout: { type: VerticalLayout.xtype, vgap: 20 },
items: [{ label: "", el: {} }],
labelWidth: "",
headerCls: "",
@ -35,7 +36,7 @@ export class Form extends Widget {
return map(o.items, (idx, item) => {
return {
type: "bi.form_field",
type: FormField.xtype,
height: item.el.height || 28,
labelAlign: o.labelAlign,
labelWidth: o.labelWidth,
@ -47,7 +48,7 @@ export class Form extends Widget {
listeners: [
{
eventName: "EVENT_CHANGE",
action () {
action() {
self.fireEvent(Form.EVENT_CHANGE, this.validate());
},
}
@ -79,8 +80,6 @@ export class Form extends Widget {
}
getValue() {
return !this.isAllValid()
? null
: map(this.group.getAllButtons(), (idx, button) => button.getValue());
return !this.isAllValid() ? null : map(this.group.getAllButtons(), (idx, button) => button.getValue());
}
}

2
src/widget/date/calendar/picker.date.js

@ -150,7 +150,7 @@ export class DatePicker extends Widget {
items: [this.right],
},
width: 24,
},
}
],
});
this.setValue({

4
src/widget/date/calendar/picker.year.js

@ -83,7 +83,7 @@ export class YearPicker extends Widget {
items: [
{
el: this.year,
},
}
],
},
{
@ -92,7 +92,7 @@ export class YearPicker extends Widget {
items: [this.right],
},
width: 25,
},
}
],
});
this.setValue(this._year);

8
src/widget/datetimepane/card.static.datetimepane.js

@ -105,7 +105,7 @@ export class StaticDateTimePaneCard extends Widget {
el: {
type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top",
ref: (_ref) => {
ref: _ref => {
this.timeSelect = _ref;
},
listeners: [
@ -115,11 +115,11 @@ export class StaticDateTimePaneCard extends Widget {
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
this.fireEvent("EVENT_CHANGE");
},
},
}
],
},
height: 40,
},
}
],
});
@ -136,7 +136,7 @@ export class StaticDateTimePaneCard extends Widget {
top: 40,
left: 0,
right: 0,
},
}
],
});
this.setValue(o.selectedTime);

20
src/widget/dynamicdate/dynamicdate.combo.js

@ -9,7 +9,7 @@ import {
isEmptyString,
isNotNull,
isNotEmptyObject,
checkDateVoid,
checkDateVoid
} from "@/core";
import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTrigger } from "./dynamicdate.trigger";
@ -75,7 +75,7 @@ export class DynamicDateCombo extends Single {
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
container: opts.container,
ref: (_ref) => {
ref: _ref => {
this.combo = _ref;
},
toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border),
height: toPix(opts.height, border),
ref: (_ref) => {
ref: _ref => {
this.changeIcon = _ref;
},
},
@ -109,7 +109,7 @@ export class DynamicDateCombo extends Single {
iconWidth: toPix(opts.height, border),
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
ref: _ref => {
this.trigger = _ref;
},
listeners: [
@ -192,9 +192,9 @@ export class DynamicDateCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
}
],
},
}
],
},
adjustLength: this.constants.comboAdjustHeight,
@ -206,7 +206,7 @@ export class DynamicDateCombo extends Single {
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
ref: _ref => {
this.popup = _ref;
},
listeners: [
@ -258,7 +258,7 @@ export class DynamicDateCombo extends Single {
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
}
],
},
},
@ -275,14 +275,14 @@ export class DynamicDateCombo extends Single {
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
},
}
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
},
}
],
};
}

18
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -76,7 +76,7 @@ export class DynamicDateTimeCombo extends Single {
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
destroyWhenHide: true,
container: opts.container,
ref: (_ref) => {
ref: _ref => {
this.combo = _ref;
},
toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateTimeCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth,
height: toPix(opts.height, border),
ref: (_ref) => {
ref: _ref => {
this.changeIcon = _ref;
},
},
@ -109,7 +109,7 @@ export class DynamicDateTimeCombo extends Single {
iconWidth: this.constants.iconWidth,
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
ref: _ref => {
this.trigger = _ref;
},
listeners: [
@ -198,9 +198,9 @@ export class DynamicDateTimeCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
}
],
},
}
],
},
adjustLength: this.constants.comboAdjustHeight,
@ -212,7 +212,7 @@ export class DynamicDateTimeCombo extends Single {
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
ref: _ref => {
this.popup = _ref;
},
listeners: [
@ -267,7 +267,7 @@ export class DynamicDateTimeCombo extends Single {
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
}
],
},
},
@ -280,7 +280,7 @@ export class DynamicDateTimeCombo extends Single {
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
},
},
}
],
// // DEC-4250 和复选下拉一样,点击不收起
// hideChecker: function (e) {
@ -291,7 +291,7 @@ export class DynamicDateTimeCombo extends Single {
left: 0,
right: 0,
bottom: 0,
},
}
],
};
}

2
src/widget/multilayerdownlist/combo.downlist.js

@ -35,7 +35,7 @@ export class MultiLayerDownListCombo extends Widget {
value: o.value,
});
this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, (value) => {
this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, value => {
this.fireEvent(MultiLayerDownListCombo.EVENT_CHANGE, value);
this.downlistcombo.hideView();
});

3
src/widget/multilayersingletree/multilayersingletree.leveltree.js

@ -178,8 +178,7 @@ export class MultiLayerSingleLevelTree extends Pane {
setValue(v) {
// getValue依赖于storeValue, 那么不选的时候就不要更新storeValue了
if (this.options.chooseType === Selection.None) {
} else {
if (this.options.chooseType !== Selection.None) {
this.storeValue = v;
this.tree.setValue(v);
}

6
src/widget/multitree/check/multi.tree.check.pane.js

@ -6,7 +6,8 @@ import {
i18nText,
nextTick,
Events,
VerticalAdaptLayout, VTapeLayout
VerticalAdaptLayout,
VTapeLayout
} from "@/core";
import { Pane, TextButton, Label } from "@/base";
import { DisplayTree, TreeView } from "@/case";
@ -123,6 +124,5 @@ export class MultiTreeCheckPane extends Pane {
this.display.setSelectedValue(v.value);
}
getValue() {
}
getValue() {}
}

87
src/widget/multitree/multi.tree.insert.combo.js

@ -1,3 +1,8 @@
import { MultiTreeSearcher } from "./trigger/searcher.multi.tree";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import {
shortcut,
extend,
@ -11,8 +16,6 @@ import {
deepClone
} from "@/core";
import { Single, Combo } from "@/base";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import { TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@ -50,7 +53,7 @@ export class MultiTreeInsertCombo extends Single {
this.storeValue = { value: o.value || {} };
this.trigger = createWidget({
type: "bi.multi_select_trigger",
type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2),
valueFormatter: o.valueFormatter,
@ -66,18 +69,16 @@ export class MultiTreeInsertCombo extends Single {
},
},
searcher: {
type: "bi.multi_tree_searcher",
type: MultiTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
type: "bi.multi_tree_search_insert_pane",
type: MultiTreeSearchInsertPane.xtype,
listeners: [
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
self.storeValue.value[
self.trigger.getSearcher().getKeyword()
] = {};
self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {};
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@ -87,8 +88,7 @@ export class MultiTreeInsertCombo extends Single {
},
},
{
eventName:
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
eventName: MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
action() {
self._dataChange = true;
},
@ -107,7 +107,7 @@ export class MultiTreeInsertCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
type: "bi.multi_tree_popup_view",
type: MultiTreePopup.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@ -135,10 +135,7 @@ export class MultiTreeInsertCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
self.fireEvent(
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@ -177,16 +174,12 @@ export class MultiTreeInsertCombo extends Single {
},
});
var change = false;
var clear = false; // 标识当前是否点击了清空
let change = false;
let clear = false; // 标识当前是否点击了清空
const isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
const isSearching = () => self.trigger.getSearcher().isSearching();
const isPopupView = function () {
return self.combo.isViewVisible();
};
const isPopupView = () => self.combo.isViewVisible();
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeInsertCombo.EVENT_FOCUS);
@ -236,14 +229,9 @@ export class MultiTreeInsertCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
this.getSearcher().setState(
checked ? BI.Selection.Multi : BI.Selection.None
);
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
self.fireEvent(
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@ -266,8 +254,7 @@ export class MultiTreeInsertCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self._stopEditing();
self._dataChange &&
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@ -275,15 +262,14 @@ export class MultiTreeInsertCombo extends Single {
if (clear === true) {
self.storeValue = { value: {} };
}
self._dataChange &&
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
var triggerBtn = createWidget({
const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@ -299,12 +285,12 @@ export class MultiTreeInsertCombo extends Single {
});
this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher",
type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@ -318,17 +304,12 @@ export class MultiTreeInsertCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
if (want2showCounter === false) {
want2showCounter = true;
}
@ -336,25 +317,19 @@ export class MultiTreeInsertCombo extends Single {
want2showCounter = null;
showCounter();
}
}
);
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});

91
src/widget/multitree/multi.tree.list.combo.js

@ -1,3 +1,6 @@
import { MultiListTreeSearcher } from "./trigger/searcher.list.multi.tree";
import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import {
shortcut,
extend,
@ -14,12 +17,7 @@ import { Single, Combo } from "@/base";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import {
TriggerIconButton,
ListPartTree,
ListDisplayTree,
Listasynctree
} from "@/case";
import { TriggerIconButton, ListPartTree, ListDisplayTree, Listasynctree } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@shortcut()
@ -57,7 +55,7 @@ export class MultiTreeListCombo extends Single {
this.storeValue = { value: o.value || [] };
this.trigger = createWidget({
type: "bi.multi_select_trigger",
type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
text: o.text,
defaultText: o.defaultText,
@ -73,12 +71,10 @@ export class MultiTreeListCombo extends Single {
},
},
searcher: {
type: "bi.multi_list_tree_searcher",
type: MultiListTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
type: o.allowInsertValue
? "bi.multi_tree_search_insert_pane"
: "bi.multi_tree_search_pane",
type: o.allowInsertValue ? "bi.multi_tree_search_insert_pane" : "bi.multi_tree_search_pane",
el: {
type: ListPartTree.xtype,
},
@ -86,9 +82,7 @@ export class MultiTreeListCombo extends Single {
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
self.storeValue.value.unshift([
self.trigger.getSearcher().getKeyword()
]);
self.storeValue.value.unshift([self.trigger.getSearcher().getKeyword()]);
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@ -102,10 +96,10 @@ export class MultiTreeListCombo extends Single {
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
el: {
type: ListDisplayTree.xtype,
},
@ -154,10 +148,7 @@ export class MultiTreeListCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
self.fireEvent(
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@ -196,16 +187,12 @@ export class MultiTreeListCombo extends Single {
},
});
var change = false;
var clear = false; // 标识当前是否点击了清空
let change = false;
let clear = false; // 标识当前是否点击了清空
const isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
const isSearching = () => self.trigger.getSearcher().isSearching();
const isPopupView = function () {
return self.combo.isViewVisible();
};
const isPopupView = () => self.combo.isViewVisible();
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeListCombo.EVENT_FOCUS);
@ -255,14 +242,9 @@ export class MultiTreeListCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
this.getSearcher().setState(
checked ? BI.Selection.Multi : BI.Selection.None
);
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
self.fireEvent(
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@ -285,8 +267,7 @@ export class MultiTreeListCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self.trigger.stopEditing();
self._dataChange &&
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@ -294,15 +275,14 @@ export class MultiTreeListCombo extends Single {
if (clear === true) {
self.storeValue = { value: [] };
}
self._dataChange &&
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
var triggerBtn = createWidget({
const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@ -318,12 +298,12 @@ export class MultiTreeListCombo extends Single {
});
this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher",
type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@ -337,17 +317,12 @@ export class MultiTreeListCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
if (want2showCounter === false) {
want2showCounter = true;
}
@ -355,27 +330,21 @@ export class MultiTreeListCombo extends Single {
want2showCounter = null;
showCounter();
}
}
);
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
});
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {

10
src/widget/multitree/multi.tree.popup.js

@ -54,9 +54,7 @@ export class MultiTreePopup extends Pane {
el: this.tree,
});
this.popupView.on(
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
index => {
this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
case 0:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
@ -64,9 +62,11 @@ export class MultiTreePopup extends Pane {
case 1:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
break;
default:
break;
}
}
);
});
this.tree.on(TreeView.EVENT_CHANGE, () => {
self.fireEvent(MultiTreePopup.EVENT_CHANGE);

17
src/widget/multitree/trigger/multi.tree.button.checkselected.js

@ -1,12 +1,4 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
i18nText,
Controller,
size
} from "@/core";
import { HorizontalLayout, shortcut, extend, emptyFn, createWidget, i18nText, Controller, size } from "@/core";
import { Single, TextButton, IconButton } from "@/base";
import { MultiSelectCheckSelectedButton } from "../../multiselect/trigger/button.checkselected";
@ -47,14 +39,11 @@ export class MultiTreeCheckSelectedButton extends Single {
});
this.checkSelected.on(TextButton.EVENT_CHANGE, function () {
self.fireEvent(
MultiSelectCheckSelectedButton.EVENT_CHANGE,
arguments
);
self.fireEvent(MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
});
createWidget({
type: "bi.horizontal",
type: HorizontalLayout.xtype,
element: this,
items: [this.indicator, this.checkSelected],
});

38
src/widget/multitree/trigger/multi.tree.search.insert.pane.js

@ -1,12 +1,4 @@
import {
shortcut,
Widget,
i18nText,
extend,
Controller,
AbsoluteLayout,
isEmptyArray
} from "@/core";
import { shortcut, Widget, i18nText, extend, Controller, AbsoluteLayout, isEmptyArray } from "@/core";
import { TreeView, PartTree } from "@/case";
import { TextButton } from "@/base";
@ -43,10 +35,7 @@ export class MultiTreeSearchInsertPane extends Widget {
height: this.constants.height,
cls: "bi-high-light",
handler() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
opts.keywordGetter()
);
self.fireEvent(MultiTreeSearchInsertPane.EVENT_ADD_ITEM, opts.keywordGetter());
},
},
top: 5,
@ -62,10 +51,7 @@ export class MultiTreeSearchInsertPane extends Widget {
op.keyword = opts.keywordGetter();
opts.itemsCreator(op, res => {
callback(res);
self.setKeyword(
opts.keywordGetter(),
res.items
);
self.setKeyword(opts.keywordGetter(), res.items);
});
},
ref(_ref) {
@ -76,26 +62,19 @@ export class MultiTreeSearchInsertPane extends Widget {
{
eventName: Controller.EVENT_CHANGE,
action() {
self.fireEvent(
Controller.EVENT_CHANGE,
arguments
);
self.fireEvent(Controller.EVENT_CHANGE, arguments);
},
},
{
eventName: TreeView.EVENT_CHANGE,
action() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_CHANGE
);
self.fireEvent(MultiTreeSearchInsertPane.EVENT_CHANGE);
},
},
{
eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() {
self.fireEvent(
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE
);
self.fireEvent(MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE);
},
}
],
@ -115,10 +94,7 @@ export class MultiTreeSearchInsertPane extends Widget {
const isAddTipVisible = isEmptyArray(nodes);
this.addTip.setVisible(isAddTipVisible);
this.partTree.setVisible(!isAddTipVisible);
isAddTipVisible &&
this.addTip.setText(
i18nText("BI-Basic_Click_To_Add_Text", keyword)
);
isAddTipVisible && this.addTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
hasChecked() {

4
src/widget/multitree/trigger/multi.tree.search.pane.js

@ -43,9 +43,7 @@ export class MultiTreeSearchPane extends Pane {
{
eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() {
self.fireEvent(
MultiTreeSearchPane.EVENT_CLICK_TREE_NODE
);
self.fireEvent(MultiTreeSearchPane.EVENT_CLICK_TREE_NODE);
},
}
],

19
src/widget/multitree/trigger/searcher.list.multi.tree.js

@ -1,15 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
isNotNull,
isNumber,
size,
each,
last
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isNumber, size, each, last } from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
import { Searcher } from "@/base";
@ -158,11 +147,7 @@ export class MultiListTreeSearcher extends Widget {
let text = "";
each(ob.value, (idx, path) => {
const childValue = last(path);
text +=
path === "null"
? ""
: `${o.valueFormatter(`${childValue}`) || childValue
}; `;
text += path === "null" ? "" : `${o.valueFormatter(`${childValue}`) || childValue}; `;
count++;
});

29
src/widget/multitree/trigger/searcher.multi.tree.js

@ -9,7 +9,8 @@ import {
size,
keys,
each,
isEmptyObject, Func
isEmptyObject,
Func
} from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
@ -48,7 +49,7 @@ export class MultiTreeSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget({
type: "bi.multi_select_editor",
type: MultiSelectEditor.xtype,
watermark: o.watermark,
height: o.height,
el: {
@ -97,13 +98,9 @@ export class MultiTreeSearcher extends Widget {
},
listeners: [
{
eventName:
MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
eventName: MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
action() {
self.fireEvent(
MultiTreeSearcher.EVENT_CLICK_TREE_NODE,
arguments
);
self.fireEvent(MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments);
},
}
],
@ -179,15 +176,9 @@ export class MultiTreeSearcher extends Widget {
const names = BI.Func.getSortedResult(keys(value));
each(names, (idx, name) => {
const childNodes = getChildrenNode(value[name]);
text +=
`${(name === "null"
? ""
: o.valueFormatter(`${name}`) || name) +
(childNodes === ""
? isEmptyObject(value[name])
? ""
: ":"
: `:${childNodes}`)
text += `${
(name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? (isEmptyObject(value[name]) ? "" : ":") : `:${childNodes}`)
}; `;
if (childNodes === "") {
count++;
@ -211,9 +202,7 @@ export class MultiTreeSearcher extends Widget {
index++;
const childNodes = getChildrenNode(ob[name]);
text +=
(name === "null"
? ""
: o.valueFormatter(`${name}`) || name) +
(name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? "" : `:${childNodes}`) +
(index === _size ? "" : ",");
if (childNodes === "") {

60
src/widget/numbereditor/number.editor.js

@ -1,23 +1,41 @@
import { shortcut, Widget, extend, emptyFn, createWidget, toPix, parseFloat, HTapeLayout, GridLayout, isNumeric, clamp, MIN, MAX, KeyCode, add } from "@/core";
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
toPix,
parseFloat,
HTapeLayout,
GridLayout,
isNumeric,
clamp,
MIN,
MAX,
KeyCode,
add
} from "@/core";
import { SignEditor } from "@/case";
import { TextEditor } from "../editor";
import { IconButton } from "@/base";
@shortcut()
export class NumberEditor extends Widget {
static xtype = "bi.number_editor"
static xtype = "bi.number_editor";
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), {
baseCls: `bi-number-editor bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
baseCls: `bi-number-editor bi-focus-shadow ${
conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
validationChecker: emptyFn,
valueFormatter (v) {
valueFormatter(v) {
return v;
},
valueParser (v) {
valueParser(v) {
return v;
},
value: 0,
@ -50,7 +68,8 @@ export class NumberEditor extends Widget {
return o.validationChecker(parsedValue);
},
errorText: o.errorText,
listeners: [{
listeners: [
{
eventName: SignEditor.EVENT_QUICK_DOWN,
action: e => {
if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
@ -98,7 +117,9 @@ export class NumberEditor extends Widget {
forceNotSelected: true,
trigger: "lclick,",
debounce: false,
cls: `${o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "}top-button bi-list-item-active2 icon-size-12`,
cls: `${
o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "
}top-button bi-list-item-active2 icon-size-12`,
});
this.topBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(o.step);
@ -110,7 +131,9 @@ export class NumberEditor extends Widget {
trigger: "lclick,",
forceNotSelected: true,
debounce: false,
cls: `${o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "}bottom-button bi-list-item-active2 icon-size-12`,
cls: `${
o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "
}bottom-button bi-list-item-active2 icon-size-12`,
});
this.bottomBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(-o.step);
@ -122,20 +145,24 @@ export class NumberEditor extends Widget {
height: toPix(o.height, 2),
element: this,
items: [
this.editor, {
this.editor,
{
el: {
type: GridLayout.xtype,
columns: 1,
rows: 2,
items: [{
items: [
{
column: 0,
row: 0,
el: this.topBtn,
}, {
},
{
column: 0,
row: 1,
el: this.bottomBtn,
}],
}
],
},
width: 23,
}
@ -165,10 +192,7 @@ export class NumberEditor extends Widget {
}
_finetuning(addValue) {
const {
max,
min,
} = this.options;
const { max, min } = this.options;
let v = parseFloat(this.getValue());
v = add(v, addValue);
v = clamp(v, min, max);

127
src/widget/numberinterval/numberinterval.js

@ -1,11 +1,25 @@
import { shortcut, extend, i18nText, createWidget, toPix, isNumeric, AbsoluteLayout, isEmptyString, isNotNull, isNull, isIE, getIEVersion } from "@/core";
import {
HorizontalFillLayout,
shortcut,
extend,
i18nText,
createWidget,
toPix,
isNumeric,
AbsoluteLayout,
isEmptyString,
isNotNull,
isNull,
isIE,
getIEVersion,
} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { IconCombo } from "@/case";
import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
@shortcut()
export class NumberInterval extends Single {
static xtype = "bi.number_interval"
static xtype = "bi.number_interval";
constants = {
typeError: "typeBubble",
@ -23,16 +37,16 @@ export class NumberInterval extends Single {
adjustYOffset: 2,
};
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: `bi-number-interval${(isIE() && getIEVersion() < 10) ? " hack" : ""}`,
extraCls: `bi-number-interval${isIE() && getIEVersion() < 10 ? " hack" : ""}`,
height: 24,
validation: "valid",
closeMin: true,
@ -47,20 +61,20 @@ export class NumberInterval extends Single {
o = this.options;
super._init(...arguments);
this.smallEditor = createWidget({
type: "bi.number_interval_single_editor",
type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.min,
level: "warning",
tipType: "success",
title () {
title() {
return self.smallEditor && self.smallEditor.getValue();
},
quitChecker () {
quitChecker() {
return false;
},
validationChecker (v) {
validationChecker(v) {
if (!isNumeric(v)) {
self.smallEditorBubbleType = c.typeError;
@ -69,7 +83,9 @@ export class NumberInterval extends Single {
return true;
},
cls: `number-interval-small-editor bi-focus-shadow ${o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"}`,
cls: `number-interval-small-editor bi-focus-shadow ${
o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"
}`,
});
this.smallTip = createWidget({
@ -81,26 +97,28 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.smallEditor,
items: [{
items: [
{
el: this.smallTip,
top: 0,
right: 5,
}],
},
],
});
this.bigEditor = createWidget({
type: "bi.number_interval_single_editor",
type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.max,
title () {
title() {
return self.bigEditor && self.bigEditor.getValue();
},
quitChecker () {
quitChecker() {
return false;
},
validationChecker (v) {
validationChecker(v) {
if (!isNumeric(v)) {
self.bigEditorBubbleType = c.typeError;
@ -109,7 +127,9 @@ export class NumberInterval extends Single {
return true;
},
cls: `number-interval-big-editor bi-focus-shadow${o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"}`,
cls: `number-interval-big-editor bi-focus-shadow${
o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"
}`,
});
this.bigTip = createWidget({
@ -121,26 +141,33 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.bigEditor,
items: [{
items: [
{
el: this.bigTip,
top: 0,
right: 5,
}],
},
],
});
this.smallCombo = createWidget({
type: IconCombo.xtype,
cls: `number-interval-small-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"}`,
cls: `number-interval-small-combo${
o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"
}`,
height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border),
items: [{
items: [
{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
}, {
},
{
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
}],
},
],
});
if (o.closeMin === true) {
this.smallCombo.setValue(1);
@ -149,18 +176,23 @@ export class NumberInterval extends Single {
}
this.bigCombo = createWidget({
type: IconCombo.xtype,
cls: `number-interval-big-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"}`,
cls: `number-interval-big-combo${
o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"
}`,
height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border),
items: [{
items: [
{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
}, {
},
{
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
}],
},
],
});
if (o.closeMax === true) {
this.bigCombo.setValue(1);
@ -178,38 +210,47 @@ export class NumberInterval extends Single {
tipType: "warning",
});
this.left = createWidget({
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", ""],
items: [{
items: [
{
el: self.smallEditor,
}, {
},
{
el: self.smallCombo,
}],
},
],
});
this.right = createWidget({
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
items: [{
items: [
{
el: self.bigCombo,
}, {
},
{
el: self.bigEditor,
// BI-23883 间距考虑边框
// lgap: 1
}],
},
],
});
createWidget({
element: self,
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
items: [
{
el: self.left,
}, {
},
{
el: self.label,
}, {
},
{
el: self.right,
}],
},
],
});
// createWidget({

62
src/widget/numberinterval/singleeditor/single.editor.js

@ -3,15 +3,15 @@ import { Single, Editor } from "@/base";
@shortcut()
export class NumberIntervalSingleEidtor extends Single {
static xtype = "bi.number_interval_single_editor"
static xtype = "bi.number_interval_single_editor";
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_VALID = "EVENT_VALID"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_CONFIRM = "EVENT_CONFIRM";
props = {
baseCls: "bi-number-interval-single-editor",
@ -25,10 +25,11 @@ export class NumberIntervalSingleEidtor extends Single {
return {
type: VerticalLayout.xtype,
items: [{
items: [
{
type: Editor.xtype,
simple: o.simple,
ref (_ref) {
ref(_ref) {
self.editor = _ref;
},
height: o.height,
@ -37,43 +38,52 @@ export class NumberIntervalSingleEidtor extends Single {
value: o.value,
quitChecker: o.quitChecker,
validationChecker: o.validationChecker,
listeners: [{
listeners: [
{
eventName: Editor.EVENT_ERROR,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
},
}, {
},
{
eventName: Editor.EVENT_FOCUS,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
},
}, {
},
{
eventName: Editor.EVENT_BLUR,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
},
}, {
},
{
eventName: Editor.EVENT_VALID,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
},
}, {
},
{
eventName: Editor.EVENT_CHANGE,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
},
}, {
},
{
eventName: Editor.EVENT_CONFIRM,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
},
}, {
},
{
eventName: Editor.EVENT_CHANGE_CONFIRM,
action () {
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
},
}],
}],
}
],
}
],
};
}

7
src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js

@ -29,8 +29,12 @@ import {
BlankSplitChar
} from "@/core";
import { Single, Combo } from "@/base";
import { MultiSelectTrigger, MultiSelectPopupView, MultiSelectCombo, SearchMultiSelectTrigger, SearchMultiSelectPopupView } from "@/widget";
import { MultiSelectBar, TriggerIconButton } from "@/case";
import { MultiSelectTrigger } from "@/widget/multiselect/multiselect.trigger";
import { MultiSelectPopupView } from "@/widget/multiselect/multiselect.popup.view";
import { MultiSelectCombo } from "@/widget/multiselect/multiselect.combo";
import { SearchMultiSelectTrigger } from "@/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search";
import { SearchMultiSelectPopupView } from "@/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search";
@shortcut()
export class SearchMultiTextValueCombo extends Single {
@ -231,7 +235,6 @@ export class SearchMultiTextValueCombo extends Single {
}
});
triggerBtn.on(TriggerIconButton.EVENT_CHANGE, () => {
this.trigger.getCounter().hideView();
if (this.combo.isViewVisible()) {

15
src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js

@ -1,6 +1,17 @@
import { shortcut, extend, emptyFn, createWidget, Events, nextTick, HTapeLayout, RightVerticalAdaptLayout } from "@/core";
import {
shortcut,
extend,
emptyFn,
createWidget,
Events,
nextTick,
HTapeLayout,
RightVerticalAdaptLayout
} from "@/core";
import { Trigger } from "@/base";
import { MultiSelectCheckSelectedSwitcher, MultiSelectSearcher, SearchMultiSelectSearcher } from "@/widget";
import { MultiSelectCheckSelectedSwitcher } from "@/widget/multiselect/trigger/switcher.checkselected";
import { MultiSelectSearcher } from "@/widget/multiselect/trigger/searcher.multiselect";
import { SearchMultiSelectSearcher } from "@/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue";
@shortcut()
export class SearchMultiSelectTrigger extends Trigger {

2
src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js

@ -1,6 +1,6 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case";
import { SearchMultiSelectLoader } from "@/widget";
import { SearchMultiSelectLoader } from "@/widget/searchmultitextvaluecombo/multitextvalue.loader.search";
@shortcut()
export class SearchMultiSelectPopupView extends Widget {

7
src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js

@ -1,6 +1,7 @@
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core";
import { Searcher } from "@/base";
import { MultiSelectEditor, MultiSelectSearchPane } from "@/widget";
import { MultiSelectEditor } from "@/widget/multiselect/trigger/editor.multiselect";
import { MultiSelectSearchPane } from "@/widget/multiselect/search/multiselect.search.pane";
@shortcut()
export class SearchMultiSelectSearcher extends Widget {
@ -173,7 +174,7 @@ export class SearchMultiSelectSearcher extends Widget {
return this.searcher.getValue();
}
populate(items) {
this.searcher.populate.apply(this.searcher, arguments);
populate(...items) {
this.searcher.populate(items);
}
}

12
src/widget/selecttree/selecttree.combo.js

@ -1,7 +1,3 @@
/**
* @class SelectTreeCombo
* @extends Widget
*/
import {
shortcut,
Widget,
@ -21,6 +17,11 @@ import { Combo } from "@/base";
import { SingleTreeTrigger } from "@/widget/singletree/singletree.trigger";
import { SelectTreePopup } from "./selecttree.popup";
/**
* @class SelectTreeCombo
* @extends Widget
*/
@shortcut()
export class SelectTreeCombo extends Widget {
static xtype = "bi.select_tree_combo";
@ -37,7 +38,8 @@ export class SelectTreeCombo extends Widget {
}
_init() {
const self = this, o = this.options;
const self = this,
o = this.options;
super._init(...arguments);
this.trigger = createWidget({

10
src/widget/selecttree/selecttree.expander.js

@ -1,12 +1,4 @@
import {
shortcut,
Widget,
extend,
createWidget,
Controller,
Events,
contains
} from "@/core";
import { shortcut, Widget, extend, createWidget, Controller, Events, contains } from "@/core";
import { Expander } from "@/base";
@shortcut()

17
src/widget/selecttree/selecttree.popup.js

@ -5,7 +5,12 @@ import {
each,
createWidget,
Controller,
isArray, isNotEmptyArray, UUID, defaults, Tree, VerticalLayout
isArray,
isNotEmptyArray,
UUID,
defaults,
Tree,
VerticalLayout
} from "@/core";
import { Pane } from "@/base";
import { BasicTreeItem, BasicTreeNode, LevelTree, TreeExpander } from "@/case";
@ -37,11 +42,7 @@ export class SelectTreePopup extends Pane {
};
node.id = node.id || UUID();
if (
node.isParent === true ||
node.parent === true ||
isNotEmptyArray(node.children)
) {
if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = true;
defaults(node, extend);
@ -102,8 +103,6 @@ export class SelectTreePopup extends Pane {
populate(items) {
super.populate(...arguments);
this.tree.populate(
this._formatItems(Tree.transformToTreeFormat(items))
);
this.tree.populate(this._formatItems(Tree.transformToTreeFormat(items)));
}
}

28
src/widget/singleselect/search/singleselect.search.loader.js

@ -1,4 +1,18 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, isUndefined, Controller, VerticalLayout, map, isArray, isKey, Func } from "@/core";
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText,
isUndefined,
Controller,
VerticalLayout,
map,
isArray,
isKey,
Func
} from "@/core";
import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "../singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -49,7 +63,7 @@ export class SingleSelectSearchLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
redmark () {
redmark() {
return true;
},
},
@ -61,7 +75,7 @@ export class SingleSelectSearchLoader extends Widget {
},
},
},
itemsCreator (op, callback) {
itemsCreator(op, callback) {
self.storeValue &&
(op = extend(op || {}, {
selectedValues: [self.storeValue],
@ -83,7 +97,7 @@ export class SingleSelectSearchLoader extends Widget {
}
});
},
hasNext () {
hasNext() {
return hasNext;
},
});
@ -98,7 +112,8 @@ export class SingleSelectSearchLoader extends Widget {
_createItems(items) {
const o = this.options;
return map(items, (i, item) => extend(
return map(items, (i, item) =>
extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
@ -110,7 +125,8 @@ export class SingleSelectSearchLoader extends Widget {
title: item.title || item.text,
},
item
));
)
);
}
_filterValues(src) {

14
src/widget/singleselect/search/singleselect.search.pane.insert.js

@ -1,4 +1,14 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout, VerticalLayout } from "@/core";
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText,
Controller,
VerticalFillLayout,
VerticalLayout
} from "@/core";
import { Label } from "@/base";
import { SingleSelectSearchLoader } from "./singleselect.search.loader";
@ -38,7 +48,7 @@ export class SingleSelectSearchInsertPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
function (res) {

2
src/widget/singleselect/search/singleselect.search.pane.js

@ -38,7 +38,7 @@ export class SingleSelectSearchPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
function (res) {

48
src/widget/singleselect/singleselect.combo.js

@ -1,4 +1,18 @@
import { shortcut, extend, emptyFn, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject, map, each, remove } from "@/core";
import {
shortcut,
extend,
emptyFn,
isKey,
createWidget,
toPix,
isNotNull,
nextTick,
AbsoluteLayout,
makeObject,
map,
each,
remove
} from "@/core";
import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -42,7 +56,7 @@ export class SingleSelectCombo extends Single {
this.requesting = false;
this.trigger = createWidget({
type: "bi.single_select_trigger",
type: SingleSelectTrigger.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
// adapter: this.popup,
allowNoSelect: o.allowNoSelect,
@ -81,15 +95,12 @@ export class SingleSelectCombo extends Single {
this.fireEvent(SingleSelectCombo.EVENT_SEARCHING);
});
this.trigger.on(
SingleSelectTrigger.EVENT_CHANGE,
(value, obj) => {
this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, (value, obj) => {
this.storeValue = this.trigger.getValue();
assertShowValue();
this._defaultState();
this._dataChange = true;
}
);
});
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
@ -104,13 +115,14 @@ export class SingleSelectCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
type: "bi.single_select_popup_view",
type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
ref: _ref => {
this.popup = _ref;
this.trigger.setAdapter(_ref);
},
listeners: [{
listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE,
action: () => {
this._dataChange = true;
@ -121,7 +133,8 @@ export class SingleSelectCombo extends Single {
});
this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
},
}],
}
],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
@ -156,8 +169,7 @@ export class SingleSelectCombo extends Single {
if (this.requesting === true) {
this.wants2Quit = true;
} else {
this._dataChange &&
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
}
});
@ -177,7 +189,8 @@ export class SingleSelectCombo extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
items: [
{
el: this.combo,
left: 0,
right: 0,
@ -209,7 +222,8 @@ export class SingleSelectCombo extends Single {
const o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_ALL_DATA,
keywords,
},
@ -233,8 +247,7 @@ export class SingleSelectCombo extends Single {
_adjust(callback) {
const adjust = () => {
if (this.wants2Quit === true) {
this._dataChange &&
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.wants2Quit = false;
}
this.requesting = false;
@ -242,7 +255,8 @@ export class SingleSelectCombo extends Single {
const o = this.options;
if (!this._count) {
o.itemsCreator({
o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
},
res => {

44
src/widget/singleselect/singleselect.insert.combo.js

@ -1,4 +1,17 @@
import { shortcut, extend, emptyFn, i18nText, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject } from "@/core";
import { SingleSelectSearchInsertPane } from "./search";
import {
shortcut,
extend,
emptyFn,
i18nText,
isKey,
createWidget,
toPix,
isNotNull,
nextTick,
AbsoluteLayout,
makeObject
} from "@/core";
import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -50,7 +63,7 @@ export class SingleSelectInsertCombo extends Single {
allowEdit: o.allowEdit,
// adapter: this.popup,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
@ -63,7 +76,7 @@ export class SingleSelectInsertCombo extends Single {
value: this.storeValue,
searcher: {
popup: {
type: "bi.single_select_search_insert_pane",
type: SingleSelectSearchInsertPane.xtype,
},
},
});
@ -93,15 +106,12 @@ export class SingleSelectInsertCombo extends Single {
self.fireEvent(SingleSelectInsertCombo.EVENT_SEARCHING);
});
this.trigger.on(
SingleSelectTrigger.EVENT_CHANGE,
function (value, obj) {
this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
self.storeValue = this.getValue();
assertShowValue();
self._defaultState();
self._dataChange = true;
}
);
});
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@ -118,30 +128,28 @@ export class SingleSelectInsertCombo extends Single {
popup: {
type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
ref () {
ref() {
self.popup = this;
self.trigger.setAdapter(this);
},
listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE,
action () {
action() {
self._dataChange = true;
self.storeValue = this.getValue();
self._adjust(() => {
assertShowValue();
self._defaultState();
});
self.fireEvent(
SingleSelectInsertCombo.EVENT_CLICK_ITEM
);
self.fireEvent(SingleSelectInsertCombo.EVENT_CLICK_ITEM);
},
}
],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
onLoaded () {
onLoaded() {
nextTick(() => {
self.combo.adjustWidth();
self.combo.adjustHeight();
@ -149,7 +157,7 @@ export class SingleSelectInsertCombo extends Single {
});
},
},
hideChecker (e) {
hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0;
},
value: o.value,
@ -172,8 +180,7 @@ export class SingleSelectInsertCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
}
});
@ -229,8 +236,7 @@ export class SingleSelectInsertCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;

6
src/widget/singleselect/singleselect.list.js

@ -35,7 +35,7 @@ export class SingleSelectList extends Widget {
this.list = createWidget(o.el, {
type: ListPane.xtype,
items: o.items,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
op.times === 1 && self.toolbar && self.toolbar.setVisible(false);
o.itemsCreator(op, function (items) {
callback.apply(self, arguments);
@ -79,13 +79,13 @@ export class SingleSelectList extends Widget {
height: this._constants.itemHeight,
forceNotSelected: true,
text: i18nText("BI-Basic_No_Select"),
ref (_ref) {
ref(_ref) {
self.toolbar = _ref;
},
listeners: [
{
eventName: Controller.EVENT_CHANGE,
action (type) {
action(type) {
if (type === Events.CLICK) {
self.list.setValue();
self.fireEvent(SingleSelectList.EVENT_CHANGE);

26
src/widget/singleselect/singleselect.loader.js

@ -1,4 +1,16 @@
import { shortcut, Widget, extend, emptyFn, createWidget, isUndefined, map, isKey, Controller, VerticalLayout, delay } from "@/core";
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
isUndefined,
map,
isKey,
Controller,
VerticalLayout,
delay
} from "@/core";
import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "./singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -52,7 +64,7 @@ export class SingleSelectLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
redmark () {
redmark() {
return true;
},
},
@ -66,7 +78,7 @@ export class SingleSelectLoader extends Widget {
},
opts.el
),
itemsCreator (op, callback) {
itemsCreator(op, callback) {
const startValue = self._startValue;
!isUndefined(self.storeValue) &&
(op = extend(op || {}, {
@ -103,7 +115,7 @@ export class SingleSelectLoader extends Widget {
op.times === 1 && self._scrollToTop();
});
},
hasNext () {
hasNext() {
return hasNext;
},
value: this.storeValue,
@ -127,7 +139,8 @@ export class SingleSelectLoader extends Widget {
_createItems(items) {
const o = this.options;
return map(items, (i, item) => extend(
return map(items, (i, item) =>
extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
@ -139,7 +152,8 @@ export class SingleSelectLoader extends Widget {
title: item.title || item.text,
},
item
));
)
);
}
_scrollToTop() {

3
src/widget/singleselect/singleselect.popup.view.js

@ -1,3 +1,4 @@
import { SingleSelectLoader } from "./singleselect.loader";
import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { MultiPopupView } from "@/case";
import { PopupView } from "@/base";
@ -27,7 +28,7 @@ export class SingleSelectPopupView extends Widget {
const opts = this.options;
this.loader = createWidget({
type: "bi.single_select_loader",
type: SingleSelectLoader.xtype,
allowNoSelect: opts.allowNoSelect,
itemsCreator: opts.itemsCreator,
itemWrapper: opts.itemWrapper,

19
src/widget/singleselect/singleselectlist.insert.js

@ -1,3 +1,4 @@
import { SingleSelectSearchInsertPane } from "./search";
import {
shortcut,
extend,
@ -68,14 +69,14 @@ export class SingleSelectInsertList extends Single {
});
this.searcherPane = createWidget({
type: "bi.single_select_search_insert_pane",
type: SingleSelectSearchInsertPane.xtype,
allowNoSelect: o.allowNoSelect,
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter () {
keywordGetter() {
return self.trigger.getKeyword();
},
itemsCreator (op, callback) {
itemsCreator(op, callback) {
op.keywords = [self.trigger.getKeyword()];
if (isNotEmptyString(op.keywords[0])) {
this.setKeyword(op.keywords[0]);
@ -93,14 +94,14 @@ export class SingleSelectInsertList extends Single {
type: SearchEditor.xtype,
watermark: i18nText("BI-Basic_Search_And_Patch_Paste"),
},
ref (ref) {
ref(ref) {
self.editor = ref;
},
height: o.searcherHeight,
},
isAutoSearch: false,
isAutoSync: false,
onSearch (op, callback) {
onSearch(op, callback) {
callback();
},
adapter: this.adapter,
@ -110,7 +111,7 @@ export class SingleSelectInsertList extends Single {
listeners: [
{
eventName: Searcher.EVENT_START,
action () {
action() {
self._showSearcherPane();
self._setStartValue();
this.setValue(deepClone(self.storeValue));
@ -118,7 +119,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_STOP,
action () {
action() {
self._showAdapter();
self._setStartValue();
self.adapter.setValue(self.storeValue);
@ -128,7 +129,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_PAUSE,
action () {
action() {
const keyword = this.getKeyword();
self.storeValue = keyword;
self._showAdapter();
@ -142,7 +143,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_CHANGE,
action () {
action() {
self.storeValue = this.getValue();
self.fireEvent(SingleSelectInsertList.EVENT_CHANGE);
},

12
src/widget/singleselect/trigger/editor.singleselect.js

@ -1,4 +1,14 @@
import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray, BlankSplitChar } from "@/core";
import {
shortcut,
Widget,
extend,
i18nText,
createWidget,
Controller,
isEmptyString,
isEmptyArray,
BlankSplitChar
} from "@/core";
import { StateEditor } from "@/case";
import { SelectPatchEditor } from "../../multiselect";

11
src/widget/singleselect/trigger/searcher.singleselect.js

@ -1,3 +1,4 @@
import { SingleSelectSearchPane } from "../search";
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isUndefined, Selection } from "@/core";
import { SingleSelectEditor } from "./editor.singleselect";
import { Searcher } from "@/base";
@ -33,11 +34,12 @@ export class SingleSelectSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget(o.el, {
type: "bi.single_select_editor",
type: SingleSelectEditor.xtype,
height: o.height,
watermark: o.watermark,
text: o.text,
listeners: [{
listeners: [
{
eventName: SingleSelectEditor.EVENT_FOCUS,
action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
@ -63,8 +65,9 @@ export class SingleSelectSearcher extends Widget {
},
el: this.editor,
popup: extend({
type: "bi.single_select_search_pane",
popup: extend(
{
type: SingleSelectSearchPane.xtype,
allowNoSelect: o.allowNoSelect,
valueFormatter: o.valueFormatter,
keywordGetter: () => this.editor.getValue(),

2
src/widget/singleslider/button/iconbutton.slider.js

@ -8,7 +8,7 @@ export class SliderIconButton extends Widget {
baseCls: "bi-single-slider-button slider-button bi-high-light-border",
height: 8,
width: 8,
}
};
constants = {
LARGE_SIZE: 16,
NORMAL_SIZE: 12,

60
src/widget/singleslider/singleslider.js

@ -1,3 +1,5 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import { SignTextEditor } from "./button/editor.sign.text";
import {
shortcut,
createWidget,
@ -32,7 +34,7 @@ export class SingleSlider extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider bi-slider-track",
@ -74,7 +76,7 @@ export class SingleSlider extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@ -98,17 +100,9 @@ export class SingleSlider extends Single {
});
// 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@ -129,7 +123,7 @@ export class SingleSlider extends Single {
}
});
this.label = createWidget({
type: "bi.sign_text_editor",
type: SignTextEditor.xtype,
cls: "slider-editor-button",
text: o.unit,
width: toPix(c.EDITOR_WIDTH, 2),
@ -140,9 +134,7 @@ export class SingleSlider extends Single {
});
this.label.element.hover(
() => {
this.label.element
.removeClass("bi-border")
.addClass("bi-border");
this.label.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.label.element.removeClass("bi-border");
@ -216,7 +208,7 @@ export class SingleSlider extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -232,8 +224,8 @@ export class SingleSlider extends Single {
this.label.setValue(v);
this.value = v;
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -247,7 +239,7 @@ export class SingleSlider extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -306,7 +298,7 @@ export class SingleSlider extends Single {
if (o.digit === false) {
valid = true;
} else {
const dotText = (`${v}`).split(".")[1] || "";
const dotText = `${v}`.split(".")[1] || "";
valid = dotText.length === o.digit;
}
}
@ -375,13 +367,9 @@ export class SingleSlider extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
@ -409,21 +397,9 @@ export class SingleSlider extends Single {
this._setVisible(true);
this.enable = true;
if (o.digit) {
this.label.setErrorText(
i18nText(
"BI-Basic_Please_Enter_Number_Between",
this.min,
this.max
)
);
this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max));
} else {
this.label.setErrorText(
i18nText(
"BI-Basic_Please_Enter_Integer_Number_Between",
this.min,
this.max
)
);
this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Integer_Number_Between", this.min, this.max));
}
if (isNumeric(this.value) || isNotEmptyString(this.value)) {

35
src/widget/singleslider/singleslider.label.js

@ -1,3 +1,4 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import {
shortcut,
createWidget,
@ -30,7 +31,7 @@ export class SingleSliderLabel extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider-label bi-slider-track",
digit: false,
@ -71,7 +72,7 @@ export class SingleSliderLabel extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@ -93,17 +94,9 @@ export class SingleSliderLabel extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@ -188,7 +181,7 @@ export class SingleSliderLabel extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -205,8 +198,8 @@ export class SingleSliderLabel extends Single {
this.value = v;
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -220,7 +213,7 @@ export class SingleSliderLabel extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -316,13 +309,9 @@ export class SingleSliderLabel extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}

35
src/widget/singleslider/singleslider.normal.js

@ -1,3 +1,4 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import {
shortcut,
createWidget,
@ -27,7 +28,7 @@ export class SingleSliderNormal extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider-normal bi-slider-track",
min: 0,
@ -52,7 +53,7 @@ export class SingleSliderNormal extends Single {
const track = this._createTrack();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
@ -75,17 +76,9 @@ export class SingleSliderNormal extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@ -147,7 +140,7 @@ export class SingleSliderNormal extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -162,8 +155,8 @@ export class SingleSliderNormal extends Single {
this.value = v;
this.fireEvent(SingleSliderNormal.EVENT_DRAG, v);
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -177,7 +170,7 @@ export class SingleSliderNormal extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -286,13 +279,9 @@ export class SingleSliderNormal extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}

9
src/widget/singletree/singletree.combo.js

@ -10,7 +10,8 @@ import {
isEmptyArray,
isEmptyString,
isArray,
contains, find
contains,
find
} from "@/core";
import { Combo } from "@/base";
import { SingleTreeTrigger } from "./singletree.trigger";
@ -25,11 +26,7 @@ export class SingleTreeCombo extends Widget {
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
baseCls:
`bi-single-tree-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
baseCls: `bi-single-tree-combo ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
trigger: {},
height: 24,
text: "",

9
src/widget/singletree/singletree.popup.js

@ -1,11 +1,4 @@
import {
shortcut,
extend,
i18nText,
createWidget,
Controller,
isArray, VerticalLayout
} from "@/core";
import { shortcut, extend, i18nText, createWidget, Controller, isArray, VerticalLayout } from "@/core";
import { Pane } from "@/base";
import { LevelTree } from "@/case";

10
src/widget/singletree/singletree.trigger.js

@ -1,12 +1,4 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
contains,
isArray,
some
} from "@/core";
import { shortcut, extend, emptyFn, createWidget, contains, isArray, some } from "@/core";
import { Trigger } from "@/base";
import { SelectTextTrigger } from "@/case";

8
src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js

@ -1,3 +1,4 @@
import { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";
import {
shortcut,
Widget,
@ -22,8 +23,9 @@ export class TextValueDownListCombo extends Widget {
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
baseCls:
`bi-text-value-down-list-combo bi-border-radius ${config.simple ? "bi-border-bottom" : "bi-border"}`,
baseCls: `bi-text-value-down-list-combo bi-border-radius ${
config.simple ? "bi-border-bottom" : "bi-border"
}`,
height: 24,
});
}
@ -46,7 +48,7 @@ export class TextValueDownListCombo extends Widget {
width: toPix(o.width, 2),
height: toPix(o.height, 2),
el: {
type: "bi.down_list_select_text_trigger",
type: DownListSelectTextTrigger.xtype,
ref: _ref => {
this.trigger = _ref;
},

69
src/widget/time/datetime.popup.js

@ -1,82 +1,107 @@
import { shortcut, Widget, i18nText, CenterAdaptLayout, GridLayout, isNull, isEmptyObject, isEmptyString } from "@/core";
import {
VTapeLayout,
shortcut,
Widget,
i18nText,
CenterAdaptLayout,
GridLayout,
isNull,
isEmptyObject,
isEmptyString
} from "@/core";
import { TextButton } from "@/base";
import { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut()
export class TimePopup extends Widget {
static xtype = "bi.time_popup"
static xtype = "bi.time_popup";
props = {
baseCls: "bi-date-time-popup",
height: 68,
};
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE"
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE";
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
render() {
const o = this.options;
return {
type: "bi.vtape",
items: [{
type: VTapeLayout.xtype,
items: [
{
el: {
type: CenterAdaptLayout.xtype,
cls: "bi-split-top",
items: [{
items: [
{
type: DynamicDateTimeSelect.xtype,
value: o.value,
ref: _ref => {
this.timeSelect = _ref;
},
}],
}
],
},
hgap: 10,
height: 44,
}, {
},
{
el: {
type: GridLayout.xtype,
items: [
[{
[
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Clears"),
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}],
}, {
}
],
},
{
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Now"),
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
},
}],
}, {
}
],
},
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
},
}],
}]
}
],
}
]
],
},
height: 24,
}],
}
],
};
}

100
src/widget/time/time.combo.js

@ -1,17 +1,27 @@
import { shortcut, toPix, getDate, isNotEmptyString, isEqual, isEmptyString, AbsoluteLayout } from "@/core";
import {
HorizontalFillLayout,
shortcut,
toPix,
getDate,
isNotEmptyString,
isEqual,
isEmptyString,
AbsoluteLayout
} from "@/core";
import { TimeTrigger } from "./time.trigger";
import { Single, IconButton, Combo } from "@/base";
import { TimePopup } from "./datetime.popup";
@shortcut()
export class TimeCombo extends Single {
static xtype = "bi.time_combo"
static xtype = "bi.time_combo";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
constants = {
popupHeight: 80,
@ -19,7 +29,7 @@ export class TimeCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
}
};
props = {
baseCls: "bi-time-combo",
@ -40,28 +50,32 @@ export class TimeCombo extends Single {
this.storeValue = opts.value;
const popup = {
type: "bi.time_popup",
type: TimePopup.xtype,
value: opts.value,
listeners: [{
listeners: [
{
eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
action: () => {
this._setNowTime();
},
}],
}
],
ref: _ref => {
this.popup = _ref;
},
@ -69,7 +83,8 @@ export class TimeCombo extends Single {
return {
type: AbsoluteLayout.xtype,
items: [{
items: [
{
el: {
type: Combo.xtype,
cls: "bi-border bi-border-radius",
@ -78,11 +93,12 @@ export class TimeCombo extends Single {
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2),
items: [{
type: "bi.time_trigger",
items: [
{
type: TimeTrigger.xtype,
height: toPix(opts.height, 2),
allowEdit: opts.allowEdit,
watermark: opts.watermark,
@ -91,7 +107,8 @@ export class TimeCombo extends Single {
ref: _ref => {
this.trigger = _ref;
},
listeners: [{
listeners: [
{
eventName: "EVENT_KEY_DOWN",
action: () => {
if (this.combo.isViewVisible()) {
@ -99,14 +116,16 @@ export class TimeCombo extends Single {
}
this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
},
}, {
},
{
eventName: "EVENT_STOP",
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
}, {
},
{
eventName: "EVENT_FOCUS",
action: () => {
this.storeTriggerValue = this.trigger.getKey();
@ -115,12 +134,14 @@ export class TimeCombo extends Single {
}
this.fireEvent("EVENT_FOCUS");
},
}, {
},
{
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
},
}, {
},
{
eventName: "EVENT_ERROR",
action: () => {
const date = getDate();
@ -131,17 +152,20 @@ export class TimeCombo extends Single {
};
this.fireEvent("EVENT_ERROR");
},
}, {
},
{
eventName: "EVENT_VALID",
action: () => {
this.fireEvent("EVENT_VALID");
},
}, {
},
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}, {
},
{
eventName: "EVENT_CONFIRM",
action: () => {
if (this.combo.isViewVisible()) {
@ -158,13 +182,16 @@ export class TimeCombo extends Single {
}
this.fireEvent("EVENT_CONFIRM");
},
}],
}, {
}
],
},
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button time-font",
width: this.constants.iconWidth,
listeners: [{
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action: () => {
if (this.combo.isViewVisible()) {
@ -173,12 +200,14 @@ export class TimeCombo extends Single {
this.combo.showView();
}
},
}],
}
],
ref: _ref => {
this.triggerBtn = _ref;
},
},
}],
}
],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
@ -187,13 +216,15 @@ export class TimeCombo extends Single {
stopPropagation: false,
},
hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
listeners: [{
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setValue(this.storeValue);
this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
}
],
ref: _ref => {
this.combo = _ref;
},
@ -202,7 +233,8 @@ export class TimeCombo extends Single {
left: 0,
right: 0,
bottom: 0,
}],
}
],
};
}

99
src/widget/time/time.trigger.js

@ -1,15 +1,43 @@
import { shortcut, i18nText, bind, isNotNull, isNotEmptyString, isEqual, AbsoluteLayout, any, print, parseDateTime, isEmptyObject, getDate, isNotEmptyObject } from "@/core";
import {
shortcut,
i18nText,
bind,
isNotNull,
isNotEmptyString,
isEqual,
AbsoluteLayout,
any,
print,
parseDateTime,
isEmptyObject,
getDate,
isNotEmptyObject
} from "@/core";
import { Trigger, Text } from "@/base";
import { SignEditor } from "@/case";
@shortcut()
export class TimeTrigger extends Trigger {
static xtype = "bi.time_trigger"
static xtype = "bi.time_trigger";
_const = {
COMPARE_FORMAT: "%H:%M:%S",
COMPLETE_COMPARE_FORMAT: "%Y-%M-%d %H:%M:%S %P",
FORMAT_ARRAY: ["%H:%M:%S", "%I:%M:%S", "%l:%M:%S", "%k:%M:%S", "%l:%M:%S %p", "%l:%M:%S %P", "%H:%M:%S %p", "%H:%M:%S %P", "%l:%M", "%k:%M", "%I:%M", "%H:%M", "%M:%S"],
FORMAT_ARRAY: [
"%H:%M:%S",
"%I:%M:%S",
"%l:%M:%S",
"%k:%M:%S",
"%l:%M:%S %p",
"%l:%M:%S %P",
"%H:%M:%S %p",
"%H:%M:%S %P",
"%l:%M",
"%k:%M",
"%I:%M",
"%H:%M",
"%M:%S"
],
DEFAULT_DATE_STRING: "2000-01-01",
DEFAULT_HOUR: "00",
};
@ -31,12 +59,13 @@ export class TimeTrigger extends Trigger {
return {
type: AbsoluteLayout.xtype,
items: [{
items: [
{
el: {
type: SignEditor.xtype,
height: o.height,
validationChecker: v => this._dateCheck(v),
quitChecker () {
quitChecker() {
return false;
},
ref: _ref => {
@ -47,38 +76,45 @@ export class TimeTrigger extends Trigger {
allowBlank: true,
watermark: o.watermark,
title: bind(this._getTitle, this),
listeners: [{
listeners: [
{
eventName: "EVENT_KEY_DOWN",
action: (...args) => {
this.fireEvent("EVENT_KEY_DOWN", ...args);
},
}, {
},
{
eventName: "EVENT_FOCUS",
action: () => {
this.storeTriggerValue = this.getKey();
this.fireEvent("EVENT_FOCUS");
},
}, {
},
{
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
},
}, {
},
{
eventName: "EVENT_STOP",
action: () => {
this.fireEvent("EVENT_STOP");
},
}, {
},
{
eventName: "EVENT_VALID",
action: () => {
this.fireEvent("EVENT_VALID");
},
}, {
},
{
eventName: "EVENT_ERROR",
action: () => {
this.fireEvent("EVENT_ERROR");
},
}, {
},
{
eventName: "EVENT_CONFIRM",
action: () => {
const value = this.editor.getValue();
@ -95,23 +131,27 @@ export class TimeTrigger extends Trigger {
}
this.fireEvent("EVENT_CONFIRM");
},
}, {
},
{
eventName: "EVENT_START",
action: () => {
this.fireEvent("EVENT_START");
},
}, {
},
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}],
}
],
},
left: 0,
right: 0,
top: 0,
bottom: 0,
}, {
},
{
el: {
type: Text.xtype,
invisible: o.allowEdit,
@ -123,14 +163,25 @@ export class TimeTrigger extends Trigger {
right: 0,
top: 0,
bottom: 0,
}],
}
],
};
}
_dateCheck(date) {
const c = this._const;
return any(c.FORMAT_ARRAY, (idx, format) => print(parseDateTime(`${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`, c.COMPLETE_COMPARE_FORMAT), format) === date);
return any(
c.FORMAT_ARRAY,
(idx, format) =>
print(
parseDateTime(
`${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`,
c.COMPLETE_COMPARE_FORMAT
),
format
) === date
);
}
_getCompleteHMS(str, format) {
@ -153,7 +204,10 @@ export class TimeTrigger extends Trigger {
}
const date = getDate();
return print(getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second), this._getFormatString());
return print(
getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second),
this._getFormatString()
);
}
_getFormatString() {
@ -163,7 +217,12 @@ export class TimeTrigger extends Trigger {
_formatValue(v) {
const now = getDate();
return isNotEmptyObject(v) ? print(getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second), this._getFormatString()) : "";
return isNotEmptyObject(v)
? print(
getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second),
this._getFormatString()
)
: "";
}
getKey() {

63
src/widget/timeinterval/dateinterval.js

@ -1,10 +1,21 @@
import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core";
import {
HorizontalFillLayout,
shortcut,
extend,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
checkDateLegal,
isNotNull
} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicDateCombo } from "../dynamicdate";
@shortcut()
export class DateInterval extends Single {
static xtype = "bi.date_interval"
static xtype = "bi.date_interval";
constants = {
height: 24,
@ -14,11 +25,10 @@ export class DateInterval extends Single {
timeErrorCls: "time-error",
};
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
@ -39,11 +49,13 @@ export class DateInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
items: [
{
el: this.left,
}, {
},
{
el: {
type: Label.xtype,
height: o.height,
@ -53,9 +65,11 @@ export class DateInterval extends Single {
this.label = _ref;
},
},
}, {
},
{
el: this.right,
}],
}
],
};
}
@ -71,12 +85,14 @@ export class DateInterval extends Single {
watermark,
value: v,
height: o.height,
listeners: [{
listeners: [
{
eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
}
],
});
combo.on(DynamicDateCombo.EVENT_ERROR, () => {
this._clearTitle();
@ -143,10 +159,12 @@ export class DateInterval extends Single {
}
_dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
return (
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
);
}
_checkVoid(obj) {
@ -159,15 +177,22 @@ export class DateInterval extends Single {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
});
})
);
}
_compare(smallDate, bigDate) {

75
src/widget/timeinterval/timeinterval.js

@ -1,10 +1,21 @@
import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core";
import {
HorizontalFillLayout,
shortcut,
extend,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
checkDateLegal,
isNotNull
} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicDateTimeCombo } from "../dynamicdatetime";
@shortcut()
export class TimeInterval extends Single {
static xtype = "bi.time_interval"
static xtype = "bi.time_interval";
constants = {
height: 24,
@ -14,9 +25,9 @@ export class TimeInterval extends Single {
timeErrorCls: "time-error",
};
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
@ -37,11 +48,13 @@ export class TimeInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
items: [
{
el: this.left,
}, {
},
{
el: {
type: Label.xtype,
height: o.height,
@ -51,9 +64,11 @@ export class TimeInterval extends Single {
this.label = _ref;
},
},
}, {
},
{
el: this.right,
}],
}
],
};
}
@ -81,7 +96,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -98,7 +118,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -121,7 +146,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
this.fireEvent(TimeInterval.EVENT_ERROR);
@ -136,10 +166,12 @@ export class TimeInterval extends Single {
}
_dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
return (
print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date;
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date
);
}
_checkVoid(obj) {
@ -152,15 +184,22 @@ export class TimeInterval extends Single {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
});
})
);
}
_compare(smallDate, bigDate) {

49
src/widget/timeinterval/timeperiods.js

@ -1,33 +1,37 @@
import { shortcut, extend } from "@/core";
import { HorizontalFillLayout, shortcut, extend } from "@/core";
import { Single, Label } from "@/base";
import { TimeCombo } from "../time";
@shortcut()
export class TimePeriods extends Single {
static xtype = "bi.time_periods"
static xtype = "bi.time_periods";
props = {
extraCls: "bi-time-interval",
value: {},
};
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
render() {
const o = this.options;
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
el: extend({
items: [
{
el: extend(
{
ref: _ref => {
this.left = _ref;
},
}, this._createCombo(o.value.start, o.watermark?.start)),
}, {
},
this._createCombo(o.value.start, o.watermark?.start)
),
},
{
el: {
type: Label.xtype,
height: o.height,
@ -37,13 +41,18 @@ export class TimePeriods extends Single {
this.label = _ref;
},
},
}, {
el: extend({
},
{
el: extend(
{
ref: _ref => {
this.right = _ref;
},
}, this._createCombo(o.value.end, o.watermark?.end)),
}],
},
this._createCombo(o.value.end, o.watermark?.end)
),
}
],
};
}
@ -55,23 +64,27 @@ export class TimePeriods extends Single {
value: v,
height: o.height,
watermark,
listeners: [{
listeners: [
{
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.left.hidePopupView();
this.right.hidePopupView();
},
}, {
},
{
eventName: TimeCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePeriods.EVENT_CHANGE);
},
}, {
},
{
eventName: TimeCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(TimePeriods.EVENT_CONFIRM);
},
}],
}
],
};
}

35
src/widget/year/card.dynamic.year.js

@ -1,3 +1,9 @@
import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
import { Bubbles, Label } from "@/base";
import { DynamicDateCard } from "@/widget/dynamicdate/dynamicdate.card";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
import { DynamicDateParamItem } from "@/widget/dynamicdate/dynamicdate.param.item";
/**
* 年份展示面板
*
@ -5,9 +11,6 @@
* @class BI.YearCard
* @extends BI.Trigger
*/
import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
import { Bubbles, Label } from "@/base";
import { DynamicDateCard, DynamicDateHelper, DynamicDateParamItem } from "@/widget";
@shortcut()
export class DynamicYearCard extends Widget {
@ -15,35 +18,41 @@ export class DynamicYearCard extends Widget {
static EVENT_CHANGE = "EVENT_CHANGE";
props = {
baseCls: "bi-year-card",
}
};
render() {
return {
type: VerticalLayout.xtype,
ref: _ref => {
this.wrapper = _ref;
},
items: [{
items: [
{
type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}, {
},
{
type: DynamicDateParamItem.xtype,
ref: _ref => {
this.item = _ref;
},
listeners: [{
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}, {
},
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide("dynamic-year-error");
},
}],
}],
}
],
}
],
vgap: 10,
hgap: 10,
};
@ -68,9 +77,7 @@ export class DynamicYearCard extends Widget {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText("BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear());
return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
setMinDate(minDate) {
@ -94,7 +101,7 @@ export class DynamicYearCard extends Widget {
const value = this.item.getValue();
return {
year: (value.offset === 0 ? -value.value : +value.value),
year: value.offset === 0 ? -value.value : +value.value,
};
}

30
src/widget/year/card.year.js

@ -1,4 +1,20 @@
import { shortcut, Widget, extend, createWidget, getDate, bind, Controller, isKey, HTapeLayout, CenterAdaptLayout, Layout, each, isNotEmptyString, checkDateVoid, parseInt } from "@/core";
import {
shortcut,
Widget,
extend,
createWidget,
getDate,
bind,
Controller,
isKey,
HTapeLayout,
CenterAdaptLayout,
Layout,
each,
isNotEmptyString,
checkDateVoid,
parseInt
} from "@/core";
import { YearCalendar } from "@/case";
import { IconButton, Navigation } from "@/base";
@ -49,10 +65,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action :() => {
this.navigation.setSelect(
this.navigation.getSelect() - 1
);
action: () => {
this.navigation.setSelect(this.navigation.getSelect() - 1);
this._checkLeftValid();
this._checkRightValid();
},
@ -69,10 +83,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action :() => {
this.navigation.setSelect(
this.navigation.getSelect() + 1
);
action: () => {
this.navigation.setSelect(this.navigation.getSelect() + 1);
this._checkLeftValid();
this._checkRightValid();
},

44
src/widget/year/combo.year.js

@ -1,8 +1,8 @@
import { IconButton, Combo } from "@/base";
import { shortcut, Widget, toPix, getDate, isNotNull, AbsoluteLayout, HorizontalFillLayout, extend } from "@/core";
import { DynamicYearTrigger } from "@/widget/year/trigger.year";
import { DynamicDateCombo } from "@/widget";
import { Combo } from "@/base";
import { DynamicYearPopup } from "@/widget/year/popup.year";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
@shortcut()
export class DynamicYearCombo extends Widget {
@ -12,18 +12,18 @@ export class DynamicYearCombo extends Widget {
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID";
static EVENT_FOCUS = "EVENT_FOCUS";
_const ={
_const = {
iconWidth: 24,
}
};
props={
props = {
baseCls: "bi-year-combo",
behaviors: {},
minDate: "1900-01-01", // 最小日期
maxDate: "2099-12-31", // 最大日期
height: 24,
supportDynamic: true,
}
};
_init() {
const o = this.options;
@ -94,21 +94,24 @@ export class DynamicYearCombo extends Widget {
ref: _ref => {
this.popup = _ref;
},
listeners: [{
listeners: [
{
eventName: DynamicYearPopup.EVENT_CHANGE,
action:() => {
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
@ -116,14 +119,16 @@ export class DynamicYearCombo extends Widget {
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}],
}
],
behaviors: o.behaviors,
min: o.minDate,
max: o.maxDate,
@ -141,7 +146,8 @@ export class DynamicYearCombo extends Widget {
BI.createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
items: [
{
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
@ -149,9 +155,10 @@ export class DynamicYearCombo extends Widget {
ref: _ref => {
this.comboWrapper = _ref;
},
items: [{
items: [
{
el: {
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: this._const.iconWidth,
height: toPix(o.height, border),
@ -159,13 +166,16 @@ export class DynamicYearCombo extends Widget {
this.changeIcon = _ref;
},
},
}, this.combo],
},
this.combo
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
}
],
});
this._checkDynamicValue(o.value);
}

106
src/widget/year/popup.year.js

@ -1,7 +1,22 @@
import { shortcut, Widget, toPix, i18nText, VerticalLayout, GridLayout, print, getDate, checkDateVoid, createItems } from "@/core";
import {
shortcut,
Widget,
toPix,
i18nText,
VerticalLayout,
GridLayout,
print,
getDate,
checkDateVoid,
createItems
} from "@/core";
import { TextButton, Tab } from "@/base";
import { DynamicDateCombo, DynamicDateHelper, DynamicYearCard, DynamicYearCombo, StaticYearCard } from "@/widget";
import { LinearSegment } from "@/case";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
import { DynamicYearCard } from "@/widget/year/card.dynamic.year";
import { DynamicYearCombo } from "@/widget/year/combo.year";
import { StaticYearCard } from "@/widget/year/card.year";
@shortcut()
export class DynamicYearPopup extends Widget {
@ -39,29 +54,21 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
this.fireEvent(
DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE
);
action: () => {
this.fireEvent(DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
},
{
type: TextButton.xtype,
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Current_Year"),
@ -72,10 +79,8 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
this.fireEvent(
DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE
);
action: () => {
this.fireEvent(DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
@ -83,32 +88,19 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
const type =
this.dateTab.getSelect();
if (
type ===
DynamicDateCombo.Dynamic
) {
this.dynamicPane.checkValidation(
true
) &&
this.fireEvent(
BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(
DynamicYearPopup.BUTTON_OK_EVENT_CHANGE
);
this.fireEvent(DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
@ -128,9 +120,7 @@ export class DynamicYearPopup extends Widget {
this.yearButton.setValue(i18nText("BI-Basic_Current_Year"));
this.yearButton.setEnable(!this._checkYearValid());
} else {
let date = DynamicDateHelper.getCalculation(
this.dynamicPane.getInputValue()
);
let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
date = print(date, "%Y");
this.yearButton.setValue(date);
this.yearButton.setEnable(false);
@ -141,13 +131,7 @@ export class DynamicYearPopup extends Widget {
const o = this.options;
const today = getDate();
return !!checkDateVoid(
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
_getTabJson() {
@ -192,7 +176,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: "EVENT_CHANGE",
action : () => {
action: () => {
this._setInnerValue(this.year, v);
},
}
@ -212,9 +196,7 @@ export class DynamicYearPopup extends Widget {
{
eventName: StaticYearCard.EVENT_CHANGE,
action: () => {
this.fireEvent(
DynamicYearPopup.EVENT_CHANGE
);
this.fireEvent(DynamicYearPopup.EVENT_CHANGE);
},
}
],
@ -227,7 +209,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action :() => {
action: () => {
const v = this.dateTab.getSelect();
switch (v) {
case DynamicYearCombo.Static: {
@ -238,14 +220,8 @@ export class DynamicYearPopup extends Widget {
}
case DynamicYearCombo.Dynamic:
default:
if (
this.storeValue &&
this.storeValue.type ===
DynamicYearCombo.Dynamic
) {
this.dynamicPane.setValue(
this.storeValue.value
);
if (this.storeValue && this.storeValue.type === DynamicYearCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
@ -264,13 +240,7 @@ export class DynamicYearPopup extends Widget {
const o = this.options;
const today = getDate();
return !!checkDateVoid(
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
setMinDate(minDate) {

40
src/widget/year/trigger.year.js

@ -1,7 +1,23 @@
import { shortcut, extend, i18nText, bind, createWidget, isPositiveInteger, checkDateVoid, parseDateTime, isNotNull, isNotEmptyString, parseInt, print, getDate, HorizontalFillLayout } from "@/core";
import {
shortcut,
extend,
i18nText,
bind,
createWidget,
isPositiveInteger,
checkDateVoid,
parseDateTime,
isNotNull,
isNotEmptyString,
parseInt,
print,
getDate,
HorizontalFillLayout
} from "@/core";
import { Trigger, TextButton } from "@/base";
import { SignEditor, TriggerIconButton } from "@/case";
import { DynamicDateCombo, DynamicDateHelper } from "@/widget";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
@shortcut()
export class DynamicYearTrigger extends Trigger {
@ -41,26 +57,18 @@ export class DynamicYearTrigger extends Trigger {
type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => (
v === "" ||
(isPositiveInteger(v) &&
!checkDateVoid(v, 1, 1, o.min, o.max)[0])
),
validationChecker: v => v === "" || (isPositiveInteger(v) && !checkDateVoid(v, 1, 1, o.min, o.max)[0]),
quitChecker: () => false,
hgap: c.hgap,
vgap: c.vgap,
watermark: o.watermark,
allowBlank: true,
errorText:v => {
errorText: v => {
if (isPositiveInteger(v)) {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText(
"BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear()
);
return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
return i18nText("BI-Year_Trigger_Invalid_Text");
@ -137,9 +145,7 @@ export class DynamicYearTrigger extends Trigger {
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
(obj.year < 0
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
(obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
return value;
@ -166,7 +172,7 @@ export class DynamicYearTrigger extends Trigger {
date = DynamicDateHelper.getCalculation(value);
const dateStr = BI.print(date, "%Y");
return BI.isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
return BI.isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
}
case DynamicDateCombo.Static:

30
src/widget/yearinterval/yearinterval.js

@ -1,4 +1,14 @@
import { shortcut, HorizontalFillLayout, createWidget, i18nText, print, parseDateTime, checkDateVoid, isNotNull, checkDateLegal } from "@/core";
import {
shortcut,
HorizontalFillLayout,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
isNotNull,
checkDateLegal
} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicYearCombo } from "../year";
@ -116,10 +126,7 @@ export class YearInterval extends Single {
}
_dateCheck(date) {
return (
print(parseDateTime(date, "%Y"), "%Y") === date ||
print(parseDateTime(date, "%Y"), "%Y") === date
);
return print(parseDateTime(date, "%Y"), "%Y") === date || print(parseDateTime(date, "%Y"), "%Y") === date;
}
_checkVoid(obj) {
@ -164,9 +171,7 @@ export class YearInterval extends Single {
smallDate = print(parseDateTime(smallDate, "%Y"), "%Y");
bigDate = print(parseDateTime(bigDate, "%Y"), "%Y");
return (
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
_setTitle(v) {
@ -189,14 +194,9 @@ export class YearInterval extends Single {
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show(
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
offsetStyle: "center",
}
);
});
this.fireEvent(YearInterval.EVENT_ERROR);
} else {
this._clearTitle();

42
src/widget/yearmonth/card.dynamic.yearmonth.js

@ -53,9 +53,7 @@ export class DynamicYearMonthCard extends Widget {
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide(
"dynamic-year-month-error"
);
Bubbles.hide("dynamic-year-month-error");
},
}
],
@ -78,9 +76,7 @@ export class DynamicYearMonthCard extends Widget {
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide(
"dynamic-year-month-error"
);
Bubbles.hide("dynamic-year-month-error");
},
}
],
@ -109,29 +105,19 @@ export class DynamicYearMonthCard extends Widget {
_checkDate(obj) {
const o = this.options;
const date = DynamicDateHelper.getCalculation(
extend(this._getValue(), this._digestDateTypeValue(obj))
);
const date = DynamicDateHelper.getCalculation(extend(this._getValue(), this._digestDateTypeValue(obj)));
return !checkDateVoid(
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
o.min,
o.max
)[0];
return !checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
}
_digestDateTypeValue(value) {
const valueMap = {};
switch (value.dateType) {
case DynamicDateCard.TYPE.YEAR:
valueMap.year =
value.offset === 0 ? -value.value : +value.value;
valueMap.year = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.MONTH:
valueMap.month =
value.offset === 0 ? -value.value : +value.value;
valueMap.month = value.offset === 0 ? -value.value : +value.value;
break;
default:
break;
@ -162,12 +148,8 @@ export class DynamicYearMonthCard extends Widget {
setValue(v) {
v = v || { year: 0, month: 0 };
this.year.setValue(
this._createValue(DynamicDateCard.TYPE.YEAR, v.year)
);
this.month.setValue(
this._createValue(DynamicDateCard.TYPE.MONTH, v.month)
);
this.year.setValue(this._createValue(DynamicDateCard.TYPE.YEAR, v.year));
this.month.setValue(this._createValue(DynamicDateCard.TYPE.MONTH, v.month));
}
_getValue() {
@ -199,13 +181,7 @@ export class DynamicYearMonthCard extends Widget {
invalid = !this._checkDate(this._getValue());
errorText = this._getErrorText();
}
invalid &&
show &&
Bubbles.show(
"dynamic-year-month-error",
errorText,
this.wrapper
);
invalid && show && Bubbles.show("dynamic-year-month-error", errorText, this.wrapper);
return !invalid;
}

20
src/widget/yearmonth/card.static.yearmonth.js

@ -30,7 +30,8 @@ export class StaticYearMonthCard extends Widget {
const month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
const items = chunk(month, 2);
return map(items, (i, item) => map(item, (j, td) => {
return map(items, (i, item) =>
map(item, (j, td) => {
return {
type: TextItem.xtype,
cls: "bi-list-item-select",
@ -46,7 +47,8 @@ export class StaticYearMonthCard extends Widget {
this.monthMap[j === 0 ? i : i + 6] = _ref;
},
};
}));
})
);
}
render() {
@ -96,9 +98,7 @@ export class StaticYearMonthCard extends Widget {
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize:
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT +
1,
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
}
)
),
@ -115,9 +115,7 @@ export class StaticYearMonthCard extends Widget {
action: () => {
this.selectedYear = this.yearPicker.getValue();
this.selectedMonth = this.month.getValue()[0];
this.fireEvent(
StaticYearMonthCard.EVENT_CHANGE
);
this.fireEvent(StaticYearMonthCard.EVENT_CHANGE);
},
}
],
@ -194,11 +192,7 @@ export class StaticYearMonthCard extends Widget {
const newObj = {};
newObj.year = obj.year || 0;
newObj.month = obj.month || 0;
if (
newObj.year === 0 ||
newObj.month === 0 ||
checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]
) {
if (newObj.year === 0 || newObj.month === 0 || checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
const year = newObj.year || getDate().getFullYear();
this.selectedYear = year;
this.selectedMonth = "";

35
src/widget/yearmonth/combo.yearmonth.js

@ -47,7 +47,7 @@ export class DynamicYearMonthCombo extends Single {
this.storeTriggerValue = "";
const border = o.simple ? 1 : 2;
this.trigger = createWidget({
type: "bi.dynamic_year_month_trigger",
type: DynamicYearMonthTrigger.xtype,
simple: o.simple,
min: o.minDate,
max: o.maxDate,
@ -103,7 +103,7 @@ export class DynamicYearMonthCombo extends Single {
minWidth: 100,
stopPropagation: false,
el: {
type: "bi.dynamic_year_month_popup",
type: DynamicYearMonthPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic,
ref: _ref => {
@ -115,26 +115,20 @@ export class DynamicYearMonthCombo extends Single {
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(
DynamicYearMonthCombo.EVENT_CONFIRM
);
this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
},
},
{
eventName:
DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
eventName: DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.comboWrapper.element.removeClass("error");
this.combo.hideView();
this.fireEvent(
DynamicYearMonthCombo.EVENT_CONFIRM
);
this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
},
},
{
eventName:
DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
eventName: DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
@ -149,8 +143,7 @@ export class DynamicYearMonthCombo extends Single {
},
},
{
eventName:
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
eventName: DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
@ -183,11 +176,7 @@ export class DynamicYearMonthCombo extends Single {
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
cls:
`${o.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"
} bi-focus-shadow`,
cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
ref: _ref => {
this.comboWrapper = _ref;
},
@ -239,13 +228,7 @@ export class DynamicYearMonthCombo extends Single {
case DynamicDateCombo.Static: {
const value = v.value || {};
return !checkDateVoid(
value.year,
value.month,
1,
o.minDate,
o.maxDate
)[0];
return !checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
}
default:
return true;

79
src/widget/yearmonth/popup.yearmonth.js

@ -13,11 +13,13 @@ import {
import { DynamicYearMonthCombo } from "./combo.yearmonth";
import { TextButton, Tab } from "@/base";
import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
// import { DynamicYearCombo } from "../year/combo.year";
import { DynamicYearCombo } from "../year/combo.year";
import { StaticYearMonthCard } from "./card.static.yearmonth";
import { LinearSegment } from "@/case";
import { DynamicYearMonthCard } from "./card.dynamic.yearmonth";
//
@shortcut()
export class DynamicYearMonthPopup extends Widget {
static xtype = "bi.dynamic_year_month_popup";
@ -54,19 +56,14 @@ export class DynamicYearMonthPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(
DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE
);
this.fireEvent(DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
@ -74,10 +71,7 @@ export class DynamicYearMonthPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Current_Month"),
disabled: this._checkTodayValid(),
@ -88,9 +82,7 @@ export class DynamicYearMonthPopup extends Widget {
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(
DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE
);
this.fireEvent(DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
@ -98,32 +90,19 @@ export class DynamicYearMonthPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type =
this.dateTab.getSelect();
if (
type ===
DynamicDateCombo.Dynamic
) {
this.dynamicPane.checkValidation(
true
) &&
this.fireEvent(
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
this.fireEvent(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
@ -143,9 +122,7 @@ export class DynamicYearMonthPopup extends Widget {
this.textButton.setValue(i18nText("BI-Basic_Current_Month"));
this.textButton.setEnable(!this._checkTodayValid());
} else {
let date = DynamicDateHelper.getCalculation(
this.dynamicPane.getInputValue()
);
let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
date = print(date, "%Y-%x");
this.textButton.setValue(date);
this.textButton.setEnable(false);
@ -156,13 +133,7 @@ export class DynamicYearMonthPopup extends Widget {
const o = this.options;
const today = getDate();
return !!checkDateVoid(
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
_getTabJson() {
@ -228,9 +199,7 @@ export class DynamicYearMonthPopup extends Widget {
{
eventName: StaticYearMonthCard.EVENT_CHANGE,
action: () => {
this.fireEvent(
DynamicYearMonthPopup.EVENT_CHANGE
);
this.fireEvent(DynamicYearMonthPopup.EVENT_CHANGE);
},
}
],
@ -247,9 +216,7 @@ export class DynamicYearMonthPopup extends Widget {
const v = this.dateTab.getSelect();
switch (v) {
case BI.DynamicYearCombo.Static: {
const date = DynamicDateHelper.getCalculation(
this.dynamicPane.getValue()
);
const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.year.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
@ -259,14 +226,8 @@ export class DynamicYearMonthPopup extends Widget {
}
case BI.DynamicYearCombo.Dynamic:
default:
if (
this.storeValue &&
this.storeValue.type ===
BI.DynamicYearCombo.Dynamic
) {
this.dynamicPane.setValue(
this.storeValue.value
);
if (this.storeValue && this.storeValue.type === BI.DynamicYearCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
@ -303,8 +264,6 @@ export class DynamicYearMonthPopup extends Widget {
const type = v.type || DynamicDateCombo.Static;
const value = v.value || v;
this.dateTab.setSelect(type);
switch (type) {
case DynamicDateCombo.Dynamic:

44
src/widget/yearmonth/trigger.yearmonth.js

@ -120,18 +120,12 @@ export class DynamicYearMonthTrigger extends Trigger {
let month = this.monthEditor.getValue();
if (isEmptyString(month)) {
month =
parseInt(v, 10) ===
parseDateTime(o.min, "%Y-%X-%d").getFullYear()
? parseDateTime(o.min, "%Y-%X-%d").getMonth() +
1
parseInt(v, 10) === parseDateTime(o.min, "%Y-%X-%d").getFullYear()
? parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1
: 1;
}
return (
v === "" ||
(isPositiveInteger(v) &&
!checkDateVoid(v, month, 1, o.min, o.max)[0])
);
return v === "" || (isPositiveInteger(v) && !checkDateVoid(v, month, 1, o.min, o.max)[0]);
}
const year = this.yearEditor.getValue();
@ -142,13 +136,7 @@ export class DynamicYearMonthTrigger extends Trigger {
v <= 12 &&
(isEmptyString(year)
? true
: !checkDateVoid(
this.yearEditor.getValue(),
v,
1,
o.min,
o.max
)[0]))
: !checkDateVoid(this.yearEditor.getValue(), v, 1, o.min, o.max)[0]))
);
},
quitChecker: () => false,
@ -156,11 +144,7 @@ export class DynamicYearMonthTrigger extends Trigger {
errorText: v => {
const year = isYear ? v : this.yearEditor.getValue();
const month = isYear ? this.monthEditor.getValue() : v;
if (
!isPositiveInteger(year) ||
!isPositiveInteger(month) ||
month > 12
) {
if (!isPositiveInteger(year) || !isPositiveInteger(month) || month > 12) {
return i18nText("BI-Year_Trigger_Invalid_Text");
}
@ -260,9 +244,7 @@ export class DynamicYearMonthTrigger extends Trigger {
type: DynamicDateCombo.Static,
value: {
year: this.yearEditor.getValue(),
month: isEmptyString(this.monthEditor.getValue())
? ""
: monthValue,
month: isEmptyString(this.monthEditor.getValue()) ? "" : monthValue,
},
};
}
@ -270,11 +252,7 @@ export class DynamicYearMonthTrigger extends Trigger {
_yearCheck(v) {
const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
return (
print(parseDateTime(v, "%Y"), "%Y") === v &&
date >= this.options.min &&
date <= this.options.max
);
return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
}
_autoSwitch(editor) {
@ -294,17 +272,13 @@ export class DynamicYearMonthTrigger extends Trigger {
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
(obj.year < 0
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
(obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
if (isNotNull(obj.month) && parseInt(obj.month) !== 0) {
value +=
Math.abs(obj.month) +
i18nText("BI-Basic_Month") +
(obj.month < 0
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
(obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
return value;

19
src/widget/yearmonthinterval/yearmonthinterval.js

@ -69,7 +69,7 @@ export class YearMonthInterval extends Single {
_createCombo(v, watermark) {
const o = this.options;
const combo = createWidget({
type: "bi.dynamic_year_month_combo",
type: DynamicYearMonthCombo.xtype,
supportDynamic: o.supportDynamic,
height: o.height,
minDate: o.minDate,
@ -81,9 +81,7 @@ export class YearMonthInterval extends Single {
{
eventName: DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(
YearMonthInterval.EVENT_BEFORE_POPUPVIEW
);
this.fireEvent(YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -175,9 +173,7 @@ export class YearMonthInterval extends Single {
smallDate = print(parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
bigDate = print(parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
return (
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
_setTitle(v) {
@ -200,14 +196,9 @@ export class YearMonthInterval extends Single {
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show(
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
offsetStyle: "center",
}
);
});
this.fireEvent(YearMonthInterval.EVENT_ERROR);
} else {
this._clearTitle();

35
src/widget/yearquarter/combo.yearquarter.js

@ -50,7 +50,7 @@ export class DynamicYearQuarterCombo extends Widget {
const border = o.simple ? 1 : 2;
this.storeTriggerValue = "";
this.trigger = createWidget({
type: "bi.dynamic_year_quarter_trigger",
type: DynamicYearQuarterTrigger.xtype,
simple: o.simple,
min: o.minDate,
max: o.maxDate,
@ -106,7 +106,7 @@ export class DynamicYearQuarterCombo extends Widget {
minWidth: 85,
stopPropagation: false,
el: {
type: "bi.dynamic_year_quarter_popup",
type: DynamicYearQuarterPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic,
ref: _ref => {
@ -118,26 +118,20 @@ export class DynamicYearQuarterCombo extends Widget {
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(
DynamicYearQuarterCombo.EVENT_CONFIRM
);
this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
},
},
{
eventName:
DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
eventName: DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.comboWrapper.element.removeClass("error");
this.combo.hideView();
this.fireEvent(
DynamicYearQuarterCombo.EVENT_CONFIRM
);
this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
},
},
{
eventName:
DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
eventName: DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
@ -152,8 +146,7 @@ export class DynamicYearQuarterCombo extends Widget {
},
},
{
eventName:
DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
eventName: DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
@ -186,11 +179,7 @@ export class DynamicYearQuarterCombo extends Widget {
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
cls:
`${o.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"
} bi-focus-shadow`,
cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
ref: _ref => {
this.comboWrapper = _ref;
},
@ -243,13 +232,7 @@ export class DynamicYearQuarterCombo extends Widget {
case DynamicDateCombo.Static:
value = v.value || {};
return !checkDateVoid(
value.year,
(value.quarter - 1) * 3 + 1,
1,
o.minDate,
o.maxDate
)[0];
return !checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
default:
return true;
}

Loading…
Cancel
Save