Browse Source

Merge pull request #217 in FUI/fineui from ~GUY/fineui:master to master

* commit '09e5f9d3e211cc7d829634a52455b81e95ffc9b4':
  样式
  relationview支持联合主键
  relationView同一层级的两个region高度不同,矮的那个下部的连线会少一截
master
guy 7 years ago
parent
commit
24fc83f1cd
  1. 8
      demo/js/widget/relationview/demo.relationview.js
  2. 3
      demo/version.js
  3. 47
      dist/bundle.js
  4. 10
      dist/bundle.min.js
  5. 3
      dist/config.js
  6. 8
      dist/demo.js
  7. 47
      dist/widget.js
  8. 35
      src/widget/relationview/relationview.item.js
  9. 2
      src/widget/relationview/relationview.js
  10. 10
      src/widget/relationview/relationview.region.js

8
demo/js/widget/relationview/demo.relationview.js

@ -11,18 +11,18 @@ Demo.RelationView = BI.inherit(BI.Widget, {
items: [ items: [
{ {
primary: { primary: {
region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () { region: "B", regionText: "比", text: ["try", "try1"], regionTitle: "bbb", regionHandler: function () {
alert("a"); alert("a");
}, },
isPrimary: true,
title: "b2...", title: "b2...",
value: "b2", text: "b2字段", value: "b2",
handler: function () { handler: function () {
alert("d"); alert("d");
} }
}, },
foreign: {region: "C", value: "c1", text: "c1字段"} foreign: {region: "C", text: ["try", "try1"], value: "c1"}
}, },
{ {
primary: {region: "A", value: "a1", text: "a1字段"}, primary: {region: "A", value: "a1", text: "a1字段"},

3
demo/version.js

@ -126,5 +126,6 @@ BI.i18n = {
"BI-Basic_Simple_Thursday": "四", "BI-Basic_Simple_Thursday": "四",
"BI-Multi_Date_Year_Prev": "年前", "BI-Multi_Date_Year_Prev": "年前",
"BI-Tiao_Data": "条数据", "BI-Tiao_Data": "条数据",
"BI-Basic_Italic": "斜体" "BI-Basic_Italic": "斜体",
"BI-Basic_Union_Relation": "联合关联"
}; };

47
dist/bundle.js vendored

@ -90879,7 +90879,6 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-relation-view-item bi-list-item-active", baseCls: "bi-relation-view-item bi-list-item-active",
height: 25,
hoverIn: BI.emptyFn, hoverIn: BI.emptyFn,
hoverOut: BI.emptyFn hoverOut: BI.emptyFn
}); });
@ -90889,29 +90888,47 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
BI.RelationViewItem.superclass._init.apply(this, arguments); BI.RelationViewItem.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.element.hover(o.hoverIn, o.hoverOut); this.element.hover(o.hoverIn, o.hoverOut);
var items = []; o.text = BI.isArray(o.text) ? o.text : [o.text];
var body = [];
var header = {
type: "bi.vertical_adapt",
cls: "primary-key-font",
items: []
};
if (o.isPrimary) { if (o.isPrimary) {
items.push({ header.items.push({
type: "bi.icon", type: "bi.icon",
width: 16, width: 16,
height: 16, height: 16,
title: BI.i18nText("BI-Primary_Key") title: BI.i18nText("BI-Primary_Key")
}); });
} }
items.push({ header.items.push({
type: "bi.label", type: "bi.label",
text: o.text, text: o.text.length > 1 ? BI.i18nText("BI-Basic_Union_Relation") : o.text[0],
value: o.value, value: o.value,
height: o.height, height: 25,
textAlign: "left", textAlign: "left",
width: o.isPrimary ? 70 : 90, width: o.isPrimary ? 70 : 90,
lgap: o.isPrimary ? 0 : 10 lgap: o.isPrimary ? 0 : 10
}); });
if(o.text.length > 1){
body = BI.map(o.text, function (idx, text) {
return {
type: "bi.label",
text: text,
value: o.value,
height: 25,
textAlign: "left",
width: 70,
lgap: 20
}
})
}
BI.createWidget({ BI.createWidget({
type: "bi.vertical_adapt", type: "bi.vertical",
element: this, element: this,
items: items, items: BI.concat([header], body),
cls: "primary-key-font",
lgap: 5 lgap: 5
}); });
}, },
@ -91161,7 +91178,7 @@ BI.RelationView = BI.inherit(BI.Widget, {
// } // }
var draw = function (i, j, direction, isForeign) { var draw = function (i, j, direction, isForeign) {
var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; var y = offsetHeights[i];
var path = "", position; var path = "", position;
switch (direction) { switch (direction) {
case top: case top:
@ -91404,7 +91421,7 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
items: [{ items: [{
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
cls: "relation-view-region-title bi-border-bottom", cls: "relation-view-region-title bi-border-bottom bi-background",
items: [this.preview, this.title] items: [this.preview, this.title]
}, this.button_group] }, this.button_group]
}], }],
@ -91416,8 +91433,10 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
_createItems: function (items) { _createItems: function (items) {
var self = this; var self = this;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
var texts = BI.isArray(item.text) ? item.text : [item.text];
return BI.extend(item, { return BI.extend(item, {
type: "bi.relation_view_item", type: "bi.relation_view_item",
height: texts.length > 1 ? (texts.length + 1) * 25 : 25,
hoverIn: function () { hoverIn: function () {
self.setValue(item.value); self.setValue(item.value);
self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
@ -91443,7 +91462,11 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
}, },
getHeight: function () { getHeight: function () {
return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; var height = 0;
BI.each(this.button_group.getAllButtons(), function (idx, button) {
height += button.getHeight();
});
return height + 25 + 2 * 20 + 3;
}, },
// 获取上方开始划线的位置 // 获取上方开始划线的位置

10
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

3
dist/config.js vendored

@ -126,5 +126,6 @@ BI.i18n = {
"BI-Basic_Simple_Thursday": "四", "BI-Basic_Simple_Thursday": "四",
"BI-Multi_Date_Year_Prev": "年前", "BI-Multi_Date_Year_Prev": "年前",
"BI-Tiao_Data": "条数据", "BI-Tiao_Data": "条数据",
"BI-Basic_Italic": "斜体" "BI-Basic_Italic": "斜体",
"BI-Basic_Union_Relation": "联合关联"
}; };

8
dist/demo.js vendored

@ -13072,18 +13072,18 @@ Demo.RelationView = BI.inherit(BI.Widget, {
items: [ items: [
{ {
primary: { primary: {
region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () { region: "B", regionText: "比", text: ["try", "try1"], regionTitle: "bbb", regionHandler: function () {
alert("a"); alert("a");
}, },
isPrimary: true,
title: "b2...", title: "b2...",
value: "b2", text: "b2字段", value: "b2",
handler: function () { handler: function () {
alert("d"); alert("d");
} }
}, },
foreign: {region: "C", value: "c1", text: "c1字段"} foreign: {region: "C", text: ["try", "try1"], value: "c1"}
}, },
{ {
primary: {region: "A", value: "a1", text: "a1字段"}, primary: {region: "A", value: "a1", text: "a1字段"},

47
dist/widget.js vendored

@ -14825,7 +14825,6 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-relation-view-item bi-list-item-active", baseCls: "bi-relation-view-item bi-list-item-active",
height: 25,
hoverIn: BI.emptyFn, hoverIn: BI.emptyFn,
hoverOut: BI.emptyFn hoverOut: BI.emptyFn
}); });
@ -14835,29 +14834,47 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
BI.RelationViewItem.superclass._init.apply(this, arguments); BI.RelationViewItem.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.element.hover(o.hoverIn, o.hoverOut); this.element.hover(o.hoverIn, o.hoverOut);
var items = []; o.text = BI.isArray(o.text) ? o.text : [o.text];
var body = [];
var header = {
type: "bi.vertical_adapt",
cls: "primary-key-font",
items: []
};
if (o.isPrimary) { if (o.isPrimary) {
items.push({ header.items.push({
type: "bi.icon", type: "bi.icon",
width: 16, width: 16,
height: 16, height: 16,
title: BI.i18nText("BI-Primary_Key") title: BI.i18nText("BI-Primary_Key")
}); });
} }
items.push({ header.items.push({
type: "bi.label", type: "bi.label",
text: o.text, text: o.text.length > 1 ? BI.i18nText("BI-Basic_Union_Relation") : o.text[0],
value: o.value, value: o.value,
height: o.height, height: 25,
textAlign: "left", textAlign: "left",
width: o.isPrimary ? 70 : 90, width: o.isPrimary ? 70 : 90,
lgap: o.isPrimary ? 0 : 10 lgap: o.isPrimary ? 0 : 10
}); });
if(o.text.length > 1){
body = BI.map(o.text, function (idx, text) {
return {
type: "bi.label",
text: text,
value: o.value,
height: 25,
textAlign: "left",
width: 70,
lgap: 20
}
})
}
BI.createWidget({ BI.createWidget({
type: "bi.vertical_adapt", type: "bi.vertical",
element: this, element: this,
items: items, items: BI.concat([header], body),
cls: "primary-key-font",
lgap: 5 lgap: 5
}); });
}, },
@ -15107,7 +15124,7 @@ BI.RelationView = BI.inherit(BI.Widget, {
// } // }
var draw = function (i, j, direction, isForeign) { var draw = function (i, j, direction, isForeign) {
var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; var y = offsetHeights[i];
var path = "", position; var path = "", position;
switch (direction) { switch (direction) {
case top: case top:
@ -15350,7 +15367,7 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
items: [{ items: [{
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
cls: "relation-view-region-title bi-border-bottom", cls: "relation-view-region-title bi-border-bottom bi-background",
items: [this.preview, this.title] items: [this.preview, this.title]
}, this.button_group] }, this.button_group]
}], }],
@ -15362,8 +15379,10 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
_createItems: function (items) { _createItems: function (items) {
var self = this; var self = this;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
var texts = BI.isArray(item.text) ? item.text : [item.text];
return BI.extend(item, { return BI.extend(item, {
type: "bi.relation_view_item", type: "bi.relation_view_item",
height: texts.length > 1 ? (texts.length + 1) * 25 : 25,
hoverIn: function () { hoverIn: function () {
self.setValue(item.value); self.setValue(item.value);
self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
@ -15389,7 +15408,11 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
}, },
getHeight: function () { getHeight: function () {
return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; var height = 0;
BI.each(this.button_group.getAllButtons(), function (idx, button) {
height += button.getHeight();
});
return height + 25 + 2 * 20 + 3;
}, },
// 获取上方开始划线的位置 // 获取上方开始划线的位置

35
src/widget/relationview/relationview.item.js

@ -10,7 +10,6 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-relation-view-item bi-list-item-active", baseCls: "bi-relation-view-item bi-list-item-active",
height: 25,
hoverIn: BI.emptyFn, hoverIn: BI.emptyFn,
hoverOut: BI.emptyFn hoverOut: BI.emptyFn
}); });
@ -20,29 +19,47 @@ BI.RelationViewItem = BI.inherit(BI.BasicButton, {
BI.RelationViewItem.superclass._init.apply(this, arguments); BI.RelationViewItem.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.element.hover(o.hoverIn, o.hoverOut); this.element.hover(o.hoverIn, o.hoverOut);
var items = []; o.text = BI.isArray(o.text) ? o.text : [o.text];
var body = [];
var header = {
type: "bi.vertical_adapt",
cls: "primary-key-font",
items: []
};
if (o.isPrimary) { if (o.isPrimary) {
items.push({ header.items.push({
type: "bi.icon", type: "bi.icon",
width: 16, width: 16,
height: 16, height: 16,
title: BI.i18nText("BI-Primary_Key") title: BI.i18nText("BI-Primary_Key")
}); });
} }
items.push({ header.items.push({
type: "bi.label", type: "bi.label",
text: o.text, text: o.text.length > 1 ? BI.i18nText("BI-Basic_Union_Relation") : o.text[0],
value: o.value, value: o.value,
height: o.height, height: 25,
textAlign: "left", textAlign: "left",
width: o.isPrimary ? 70 : 90, width: o.isPrimary ? 70 : 90,
lgap: o.isPrimary ? 0 : 10 lgap: o.isPrimary ? 0 : 10
}); });
if(o.text.length > 1){
body = BI.map(o.text, function (idx, text) {
return {
type: "bi.label",
text: text,
value: o.value,
height: 25,
textAlign: "left",
width: 70,
lgap: 20
}
})
}
BI.createWidget({ BI.createWidget({
type: "bi.vertical_adapt", type: "bi.vertical",
element: this, element: this,
items: items, items: BI.concat([header], body),
cls: "primary-key-font",
lgap: 5 lgap: 5
}); });
}, },

2
src/widget/relationview/relationview.js

@ -233,7 +233,7 @@ BI.RelationView = BI.inherit(BI.Widget, {
// } // }
var draw = function (i, j, direction, isForeign) { var draw = function (i, j, direction, isForeign) {
var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2;
var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; var y = offsetHeights[i];
var path = "", position; var path = "", position;
switch (direction) { switch (direction) {
case top: case top:

10
src/widget/relationview/relationview.region.js

@ -65,7 +65,7 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"),
items: [{ items: [{
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
cls: "relation-view-region-title bi-border-bottom", cls: "relation-view-region-title bi-border-bottom bi-background",
items: [this.preview, this.title] items: [this.preview, this.title]
}, this.button_group] }, this.button_group]
}], }],
@ -77,8 +77,10 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
_createItems: function (items) { _createItems: function (items) {
var self = this; var self = this;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
var texts = BI.isArray(item.text) ? item.text : [item.text];
return BI.extend(item, { return BI.extend(item, {
type: "bi.relation_view_item", type: "bi.relation_view_item",
height: texts.length > 1 ? (texts.length + 1) * 25 : 25,
hoverIn: function () { hoverIn: function () {
self.setValue(item.value); self.setValue(item.value);
self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value);
@ -104,7 +106,11 @@ BI.RelationViewRegion = BI.inherit(BI.BasicButton, {
}, },
getHeight: function () { getHeight: function () {
return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; var height = 0;
BI.each(this.button_group.getAllButtons(), function (idx, button) {
height += button.getHeight();
});
return height + 25 + 2 * 20 + 3;
}, },
// 获取上方开始划线的位置 // 获取上方开始划线的位置

Loading…
Cancel
Save