Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/ElemeFE/element into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
qixiang.wqx committed Jun 12, 2019
2 parents d27b8b4 + 5440186 commit c3345e5
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 65 deletions.
11 changes: 5 additions & 6 deletions examples/components/footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<a href="https://github.com/ElemeFE/element/releases" class="footer-main-link" target="_blank">{{ langConfig.changelog }}</a>
<a href="https://github.com/ElemeFE/element/blob/dev/FAQ.md" class="footer-main-link" target="_blank">{{ langConfig.faq }}</a>
<a href="https://github.com/ElementUI/element-starter" class="footer-main-link" target="_blank">{{ langConfig.starter }}</a>
<a href="https://github.com/ElementUI/element-theme" class="footer-main-link" target="_blank">{{ langConfig.theme }}</a>
<a href="https://github.com/ElementUI/theme-chalk-preview" class="footer-main-link" target="_blank">{{ langConfig.preview }}</a>
<a :href="'/#/' + lang + '/component/custom-theme'" class="footer-main-link" target="_blank">{{ langConfig.theme }}</a>
<a href="https://github.com/elemefe/element-react" class="footer-main-link" target="_blank">Element-React</a>
<a href="https://github.com/ElemeFE/element-angular" class="footer-main-link" target="_blank">Element-Angular</a>
</div>
Expand Down Expand Up @@ -62,7 +61,7 @@
display: inline-block;
vertical-align: top;
margin-right: 110px;
h4 {
font-size: 18px;
color: #333;
Expand All @@ -86,7 +85,7 @@
.footer-social {
float: right;
text-align: right;
.footer-social-title {
color: #666;
font-size: 18px;
Expand Down Expand Up @@ -144,13 +143,13 @@
height: auto;
}
}
@media (max-width: 1000px) {
.footer-social {
display: none;
}
}
@media (max-width: 768px) {
.footer {
.footer-main {
Expand Down
3 changes: 2 additions & 1 deletion examples/components/theme-configurator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
export default {
props: {
themeConfig: Object,
previewConfig: Object,
isOfficial: Boolean,
onUserConfigUpdate: Function
},
Expand Down Expand Up @@ -155,7 +156,7 @@ export default {
this.onAction();
},
onDownload() {
bus.$emit(ACTION_DOWNLOAD_THEME, this.userConfig);
bus.$emit(ACTION_DOWNLOAD_THEME, this.userConfig, this.previewConfig.name);
},
onAction() {
this.onUserConfigUpdate(this.userConfig);
Expand Down
8 changes: 4 additions & 4 deletions examples/components/theme/loader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default {
this.userConfig = val;
this.onAction();
});
bus.$on(ACTION_DOWNLOAD_THEME, val => {
this.onDownload(val);
bus.$on(ACTION_DOWNLOAD_THEME, (themeConfig, themeName) => {
this.onDownload(themeConfig, themeName);
});
},
data() {
Expand All @@ -41,7 +41,7 @@ export default {
});
this.lastApply = time;
},
onDownload(themeConfig) {
onDownload(themeConfig, themeName) {
this.triggertProgressBar(true);
updateVars(
Object.assign({}, themeConfig, { download: true }),
Expand All @@ -55,7 +55,7 @@ export default {
.then(() => {
this.triggertProgressBar(false);
});
ga('send', 'event', 'ThemeConfigurator', 'Download');
ga('send', 'event', 'ThemeConfigurator', 'Download', themeName);
},
onAction() {
this.triggertProgressBar(true);
Expand Down
16 changes: 8 additions & 8 deletions examples/components/theme/theme-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}
&.is-upload:hover {
box-shadow: none;
}
}
&:hover {
box-shadow: 0 0 10px 0 #999;
Expand All @@ -172,10 +172,10 @@
<span>{{getActionDisplayName('upload-theme')}}</span>
</div>
</div>
<input
class="el-upload__input"
type="file"
ref="input"
<input
class="el-upload__input"
type="file"
ref="input"
@change="uploadAction"
accept="application/json"
/>
Expand Down Expand Up @@ -224,8 +224,8 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="rename">{{getActionDisplayName('rename-theme')}}</el-dropdown-item>
<el-dropdown-item command="copy">{{getActionDisplayName('copy-theme')}}</el-dropdown-item>
<el-dropdown-item
command="delete"
<el-dropdown-item
command="delete"
style="color: #F56C6C;"
>
{{getActionDisplayName('delete-theme')}}
Expand Down Expand Up @@ -325,7 +325,7 @@ export default {
});
break;
case 'download':
bus.$emit(ACTION_DOWNLOAD_THEME, this.theme);
bus.$emit(ACTION_DOWNLOAD_THEME, this.theme, this.config.name);
break;
default:
this.$emit('action', e, this.config);
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/zh-CN/divider.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@
### Divider Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------------- |---------------- |---------------- |---------------------- |-------- |
| direction | 设置分割线方向 | boolean | horizontal / vertical | horizontal |
| direction | 设置分割线方向 | string | horizontal / vertical | horizontal |
| content-position | 设置分割线文案的位置 | string | left / right / center | center |
12 changes: 4 additions & 8 deletions examples/i18n/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"repo": "代码仓库",
"community": "社区",
"changelog": "更新日志",
"theme": "自定义主题工具",
"preview": "在线主题生成",
"theme": "在线主题生成器",
"faq": "常见问题",
"gitter": "在线讨论",
"starter": "脚手架",
Expand Down Expand Up @@ -44,8 +43,7 @@
"repo": "GitHub",
"community": "Community",
"changelog": "Changelog",
"theme": "Theme CLI tool",
"preview": "Online theme generator",
"theme": "Online Theme Roller",
"faq": "FAQ",
"gitter": "Gitter",
"starter": "Starter kit",
Expand Down Expand Up @@ -76,8 +74,7 @@
"repo": "GitHub",
"community": "Comunidad",
"changelog": "Lista de cambios",
"theme": "Generador de temas por CLI",
"preview": "Generador de temas en línea",
"theme": "Online Theme Roller",
"faq": "FAQ",
"gitter": "Gitter",
"starter": "Kit de inicio",
Expand Down Expand Up @@ -108,8 +105,7 @@
"repo": "GitHub",
"community": "Communauté",
"changelog": "Changelog",
"theme": "Générateur de thème (CLI)",
"preview": "Générateur de thème en ligne",
"theme": "Online Theme Roller",
"faq": "FAQ",
"gitter": "Gitter",
"starter": "Kit de démarrage",
Expand Down
4 changes: 3 additions & 1 deletion examples/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
});
</script><% } %>
<% if (process.env.NODE_ENV !== 'production') { %><script>
var ga = function() {};
var ga = function() {
console.log(arguments)
};
</script><% } %>
</html>
1 change: 1 addition & 0 deletions examples/pages/template/theme-preview.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<theme-configurator
:isOfficial="isOfficial"
:themeConfig="themeConfig"
:previewConfig="previewConfig"
:onUserConfigUpdate="onUserConfigUpdate"
>
</theme-configurator>
Expand Down
3 changes: 3 additions & 0 deletions packages/menu/src/submenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
this.dispatch('ElSubmenu', 'mouse-leave-child');
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
if (this.appendToBody) {
this.rootMenu.openedMenus = [];
}
!this.mouseInChild && this.rootMenu.closeMenu(this.index);
}, this.hideTimeout);
},
Expand Down
3 changes: 2 additions & 1 deletion packages/select/src/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@
small: 32,
mini: 28
};
this.initialInputHeight = reference.$el.getBoundingClientRect().height || sizeMap[this.selectSize];
const input = reference.$el.querySelector('input');
this.initialInputHeight = input.getBoundingClientRect().height || sizeMap[this.selectSize];
}
if (this.remote && this.multiple) {
this.resetInputHeight();
Expand Down
1 change: 1 addition & 0 deletions packages/table/src/store/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default {
} else {
const { loaded = false, loading = false } = oldValue || {};
newTreeData[key] = {
lazy: true,
loaded: !!loaded,
loading: !!loading,
expanded: getExpanded(oldValue, key),
Expand Down
15 changes: 7 additions & 8 deletions packages/table/src/table-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ export default {
indent: treeRowData.level * treeIndent,
level: treeRowData.level
};
// TODO: 优化这里的逻辑
if (typeof treeRowData.expanded === 'boolean') {
data.treeNode.expanded = treeRowData.expanded;
// 表明是懒加载
Expand Down Expand Up @@ -418,10 +417,10 @@ export default {
level: cur.level,
display: true
};
if (typeof cur.loaded === 'boolean' && cur.loaded) {
treeRowData.noLazyChildren = !(cur.children && cur.children.length);
}
if (typeof cur.loading === 'boolean') {
if (typeof cur.lazy === 'boolean') {
if (typeof cur.loaded === 'boolean' && cur.loaded) {
treeRowData.noLazyChildren = !(cur.children && cur.children.length);
}
treeRowData.loading = cur.loading;
}
}
Expand Down Expand Up @@ -451,10 +450,10 @@ export default {
// 懒加载的某些节点,level 未知
cur.level = cur.level || innerTreeRowData.level;
cur.display = !!(cur.expanded && innerTreeRowData.display);
if (typeof cur.loaded === 'boolean' && cur.loaded) {
innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
}
if (typeof cur.lazy === 'boolean') {
if (typeof cur.loaded === 'boolean' && cur.loaded) {
innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
}
innerTreeRowData.loading = cur.loading;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/theme-chalk/src/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
&, &.el-table__row--striped {
&, &.current-row {
> td {
background-color: $--table-current-row-background-color;
background-color: $--table-row-hover-background-color;
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/tree/src/model/node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import objectAssign from 'element-ui/src/utils/merge';
import { markNodeData, NODE_KEY } from './util';
import { arrayFindIndex } from 'element-ui/src/utils/util';

export const getChildState = node => {
let all = true;
Expand Down Expand Up @@ -435,8 +436,10 @@ export default class Node {
const newNodes = [];

newData.forEach((item, index) => {
if (item[NODE_KEY]) {
newDataMap[item[NODE_KEY]] = { index, data: item };
const key = item[NODE_KEY];
const isNodeExists = !!key && arrayFindIndex(oldData, data => data[NODE_KEY] === key) >= 0;
if (isNodeExists) {
newDataMap[key] = { index, data: item };
} else {
newNodes.push({ index, data: item });
}
Expand Down
4 changes: 2 additions & 2 deletions src/locale/lang/fa.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export default {
hasCheckedFormat: '{checked} مورد از {total} مورد انتخاب شده است'
},
image: {
error: 'FAILED' // to be translated
error: 'خطا در بارگیری تصویر'
},
pageHeader: {
title: 'Back' // to be translated
title: 'بازگشت'
}
}
};
61 changes: 60 additions & 1 deletion test/unit/specs/tree.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createVue, destroyVM, waitImmediate } from '../util';
import { createVue, destroyVM, waitImmediate, wait } from '../util';

const DELAY = 10;

Expand Down Expand Up @@ -831,4 +831,63 @@ describe('Tree', () => {
done();
});
});

it('update multi tree data', async() => {
const vm = createVue({
template: `
<div>
<el-tree ref="tree1" :data="data" node-key="id" :props="defaultProps"></el-tree>
<el-tree ref="tree2" :data="data" node-key="id" :props="defaultProps"></el-tree>
</div>
`,

data() {
return {
data: [{
id: 1,
label: '一级 1',
children: [{
id: 11,
label: '二级 1-1',
children: [{
id: 111,
label: '三级 1-1'
}]
}]
}, {
id: 2,
label: '一级 2',
children: [{
id: 21,
label: '二级 2-1'
}, {
id: 22,
label: '二级 2-2'
}]
}, {
id: 3,
label: '一级 3',
children: [{
id: 31,
label: '二级 3-1'
}, {
id: 32,
label: '二级 3-2'
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
}
}, true);
const nodeData = { label: '新增 1', id: 4 };
vm.data.push(nodeData);
await wait();
const tree1 = vm.$refs.tree1;
expect(tree1.getNode(4).data).to.equal(nodeData);
const tree2 = vm.$refs.tree2;
expect(tree2.getNode(4).data).to.equal(nodeData);
});
});
Loading

0 comments on commit c3345e5

Please sign in to comment.