show ViewTabsAutoExpand

This commit is contained in:
devezhao 2020-12-22 17:47:27 +08:00
parent a04e6dd5b4
commit ed4c54d371
3 changed files with 18 additions and 8 deletions

View file

@ -140,13 +140,12 @@ body {
.related-list .card { .related-list .card {
border: 1px solid #ebebeb; border: 1px solid #ebebeb;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.04);
padding: 0; padding: 0;
margin-bottom: 9px; margin-bottom: 9px;
} }
.related-list .card:hover { .related-list .card:hover {
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
} }
.related-list .card .header-title { .related-list .card .header-title {

View file

@ -249,7 +249,7 @@ class RelatedList extends React.Component {
)} )}
{(this.state.list || []).map((item) => { {(this.state.list || []).map((item) => {
return ( return (
<div className={`card ${this.state.viewOpens[item[0]] ? 'active' : ''}`} key={`rr-${item[0]}`}> <div className={`card ${this.state.viewOpens[item[0]] ? 'active' : ''}`} key={item[0]} ref={`item-${item[0]}`}>
<div className="row header-title" onClick={() => this._toggleInsideView(item[0])}> <div className="row header-title" onClick={() => this._toggleInsideView(item[0])}>
<div className="col-10"> <div className="col-10">
<a href={`#!/View/${this.props.entity.split('.')[0]}/${item[0]}`} onClick={(e) => this._handleView(e)} title={$L('Open')}> <a href={`#!/View/${this.props.entity.split('.')[0]}/${item[0]}`} onClick={(e) => this._handleView(e)} title={$L('Open')}>
@ -284,11 +284,21 @@ class RelatedList extends React.Component {
fetchList(append) { fetchList(append) {
this.__pageNo = this.__pageNo || 1 this.__pageNo = this.__pageNo || 1
if (append) this.__pageNo += append if (append) this.__pageNo += append
const pageSize = 20 const pageSize = 5
$.get(`/app/entity/related-list?mainid=${this.props.main}&related=${this.props.entity}&pageNo=${this.__pageNo}&pageSize=${pageSize}`, (res) => { $.get(`/app/entity/related-list?mainid=${this.props.main}&related=${this.props.entity}&pageNo=${this.__pageNo}&pageSize=${pageSize}`, (res) => {
const _data = res.data.data || [] const data = res.data.data || []
const _list = (this.state.list || []).concat(_data) const list = (this.state.list || []).concat(data)
this.setState({ list: _list, showMores: _data.length >= pageSize })
this.setState({ list: list, showMores: data.length >= pageSize }, () => {
if (this.props.autoExpand) {
data.forEach((item) => {
// eslint-disable-next-line react/no-string-refs
const $H = $(this.refs[`item-${item[0]}`]).find('.header-title')
if ($H.length > 0) $H[0].click()
})
}
})
}) })
} }
@ -551,7 +561,7 @@ const RbViewPage = {
const tabNav = $(`<li class="nav-item"><a class="nav-link" href="#${tabId}" data-toggle="tab" title="${this.entityLabel}">${this.entityLabel}</a></li>`).appendTo('.nav-tabs') const tabNav = $(`<li class="nav-item"><a class="nav-link" href="#${tabId}" data-toggle="tab" title="${this.entityLabel}">${this.entityLabel}</a></li>`).appendTo('.nav-tabs')
const tabPane = $(`<div class="tab-pane" id="${tabId}"></div>`).appendTo('.tab-content') const tabPane = $(`<div class="tab-pane" id="${tabId}"></div>`).appendTo('.tab-content')
tabNav.find('a').click(function () { tabNav.find('a').click(function () {
tabPane.find('.related-list').length === 0 && renderRbcomp(<MixRelatedList entity={entity} main={that.__id} />, tabPane) tabPane.find('.related-list').length === 0 && renderRbcomp(<MixRelatedList entity={entity} main={that.__id} autoExpand={$isTrue(wpc.viewTabsAutoExpand)} />, tabPane)
}) })
}) })
this.updateVTabs() this.updateVTabs()

View file

@ -103,6 +103,7 @@
entity: ['[[${entityName}]]', '[[${entityLabel}]]', '[[${entityIcon}]]'], entity: ['[[${entityName}]]', '[[${entityLabel}]]', '[[${entityIcon}]]'],
privileges: _$unthy('[[${entityPrivileges}]]'), privileges: _$unthy('[[${entityPrivileges}]]'),
viewTabs: _$unthy('[[${ViewTabs}]]'), viewTabs: _$unthy('[[${ViewTabs}]]'),
viewTabsAutoExpand: '[[${ViewTabsAutoExpand}]]',
viewAdds: _$unthy('[[${ViewAdds}]]'), viewAdds: _$unthy('[[${ViewAdds}]]'),
transformTos: _$unthy('[[${TransformTos}]]'), transformTos: _$unthy('[[${TransformTos}]]'),
recordId: '[[${id}]]', recordId: '[[${id}]]',