chore(ProfileShowcaseDirtyState): integration with Constants.ShowcaseVisibility enum
This commit is contained in:
parent
29c15a5bff
commit
94f250d671
|
@ -9,6 +9,8 @@ import Storybook 1.0
|
||||||
|
|
||||||
import AppLayouts.Profile.helpers 1.0
|
import AppLayouts.Profile.helpers 1.0
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
@ -24,8 +26,33 @@ Item {
|
||||||
ListModel {
|
ListModel {
|
||||||
id: communitiesShowcaseModel
|
id: communitiesShowcaseModel
|
||||||
|
|
||||||
ListElement { key: "1"; visibility: 1; position: 0 }
|
ListElement {
|
||||||
ListElement { key: "3"; visibility: 2; position: 9 }
|
key: "1"
|
||||||
|
visibility: Constants.ShowcaseVisibility.IdVerifiedContacts
|
||||||
|
position: 0
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
key: "3"
|
||||||
|
visibility: Constants.ShowcaseVisibility.Contacts
|
||||||
|
position: 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel {
|
||||||
|
id: comboBoxModel
|
||||||
|
|
||||||
|
ListElement {
|
||||||
|
text: "verified"
|
||||||
|
value: Constants.ShowcaseVisibility.IdVerifiedContacts
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "contacts"
|
||||||
|
value: Constants.ShowcaseVisibility.Contacts
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "all"
|
||||||
|
value: Constants.ShowcaseVisibility.Everyone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileShowcaseDirtyState {
|
ProfileShowcaseDirtyState {
|
||||||
|
@ -130,17 +157,13 @@ Item {
|
||||||
|
|
||||||
RoundButton {
|
RoundButton {
|
||||||
text: "❌"
|
text: "❌"
|
||||||
onClicked: dirtyState.setVisibility(model.key, 0)
|
onClicked: dirtyState.setVisibility(
|
||||||
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.NoOne)
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: combo
|
model: comboBoxModel
|
||||||
|
|
||||||
model: ListModel {
|
|
||||||
ListElement { text: "contacts"; value: 1 }
|
|
||||||
ListElement { text: "verified"; value: 2 }
|
|
||||||
ListElement { text: "all"; value: 3 }
|
|
||||||
}
|
|
||||||
|
|
||||||
onCurrentValueChanged: {
|
onCurrentValueChanged: {
|
||||||
if (!completed || topModel.index < 0)
|
if (!completed || topModel.index < 0)
|
||||||
|
@ -174,7 +197,9 @@ Item {
|
||||||
insetComponent: Button {
|
insetComponent: Button {
|
||||||
text: "unhide"
|
text: "unhide"
|
||||||
|
|
||||||
onClicked: dirtyState.setVisibility(model.key, 1)
|
onClicked: dirtyState.setVisibility(
|
||||||
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.IdVerifiedContacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,16 @@ ColumnLayout {
|
||||||
ListModel {
|
ListModel {
|
||||||
id: accountsShowcaseModel
|
id: accountsShowcaseModel
|
||||||
|
|
||||||
ListElement { key: "1"; visibility: 1; position: 0 }
|
ListElement {
|
||||||
ListElement { key: "3"; visibility: 2; position: 9 }
|
key: "1"
|
||||||
|
visibility: Constants.ShowcaseVisibility.IdVerifiedContacts
|
||||||
|
position: 0
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
key: "3"
|
||||||
|
visibility: Constants.ShowcaseVisibility.Contacts
|
||||||
|
position: 9
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
|
@ -41,9 +49,21 @@ ColumnLayout {
|
||||||
ListModel {
|
ListModel {
|
||||||
id: collectiblesShowcaseModel
|
id: collectiblesShowcaseModel
|
||||||
|
|
||||||
ListElement { key: "1"; visibility: 1; position: 0 }
|
ListElement {
|
||||||
ListElement { key: "2"; visibility: 2; position: 2 }
|
key: "1"
|
||||||
ListElement { key: "3"; visibility: 2; position: 1 }
|
visibility: Constants.ShowcaseVisibility.IdVerifiedContacts
|
||||||
|
position: 0
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
key: "2"
|
||||||
|
visibility: Constants.ShowcaseVisibility.Contacts
|
||||||
|
position: 2
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
key: "3"
|
||||||
|
visibility: Constants.ShowcaseVisibility.Contacts
|
||||||
|
position: 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileShowcaseModels {
|
ProfileShowcaseModels {
|
||||||
|
@ -68,12 +88,25 @@ ColumnLayout {
|
||||||
sourceModel: showcaseModels.collectiblesVisibleModel
|
sourceModel: showcaseModels.collectiblesVisibleModel
|
||||||
}
|
}
|
||||||
|
|
||||||
component VisibilityComboBox: ComboBox {
|
ListModel {
|
||||||
model: ListModel {
|
id: comboBoxModel
|
||||||
ListElement { text: "contacts"; value: 1 }
|
|
||||||
ListElement { text: "verified"; value: 2 }
|
ListElement {
|
||||||
ListElement { text: "all"; value: 3 }
|
text: "verified"
|
||||||
|
value: Constants.ShowcaseVisibility.IdVerifiedContacts
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "contacts"
|
||||||
|
value: Constants.ShowcaseVisibility.Contacts
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "all"
|
||||||
|
value: Constants.ShowcaseVisibility.Everyone
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component VisibilityComboBox: ComboBox {
|
||||||
|
model: comboBoxModel
|
||||||
|
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
valueRole: "value"
|
valueRole: "value"
|
||||||
|
@ -150,7 +183,8 @@ ColumnLayout {
|
||||||
RoundButton {
|
RoundButton {
|
||||||
text: "❌"
|
text: "❌"
|
||||||
onClicked: showcaseModels.setAccountVisibility(
|
onClicked: showcaseModels.setAccountVisibility(
|
||||||
model.key, 0)
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.NoOne)
|
||||||
}
|
}
|
||||||
|
|
||||||
VisibilityComboBox {
|
VisibilityComboBox {
|
||||||
|
@ -185,8 +219,10 @@ ColumnLayout {
|
||||||
insetComponent: Button {
|
insetComponent: Button {
|
||||||
text: "unhide"
|
text: "unhide"
|
||||||
|
|
||||||
onClicked: showcaseModels.setAccountVisibility(
|
onClicked:
|
||||||
model.key, 1)
|
showcaseModels.setAccountVisibility(
|
||||||
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.IdVerifiedContacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +279,8 @@ ColumnLayout {
|
||||||
RoundButton {
|
RoundButton {
|
||||||
text: "❌"
|
text: "❌"
|
||||||
onClicked: showcaseModels.setCollectibleVisibility(
|
onClicked: showcaseModels.setCollectibleVisibility(
|
||||||
model.key, 0)
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.NoOne)
|
||||||
}
|
}
|
||||||
|
|
||||||
VisibilityComboBox {
|
VisibilityComboBox {
|
||||||
|
@ -279,8 +316,10 @@ ColumnLayout {
|
||||||
insetComponent: Button {
|
insetComponent: Button {
|
||||||
text: "unhide"
|
text: "unhide"
|
||||||
|
|
||||||
onClicked: showcaseModels.setCollectibleVisibility(
|
onClicked:
|
||||||
model.key, 1)
|
showcaseModels.setCollectibleVisibility(
|
||||||
|
model.key,
|
||||||
|
Constants.ShowcaseVisibility.IdVerifiedContacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Building block for managing temporary state in the "Profile Showcase"
|
* Building block for managing temporary state in the "Profile Showcase"
|
||||||
* functionality. Provides combining raw source model (like e.g. communities
|
* functionality. Provides combining raw source model (like e.g. communities
|
||||||
|
@ -45,9 +47,15 @@ QObject {
|
||||||
readonly property alias writable_: writable
|
readonly property alias writable_: writable
|
||||||
readonly property alias joined_: joined
|
readonly property alias joined_: joined
|
||||||
|
|
||||||
component VisibilityFilter: RangeFilter {
|
component HiddenFilter: AnyOf {
|
||||||
roleName: "visibility"
|
UndefinedFilter {
|
||||||
minimumValue: 1
|
roleName: "visibility"
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueFilter {
|
||||||
|
roleName: "visibility"
|
||||||
|
value: Constants.ShowcaseVisibility.NoOne
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftJoinModel {
|
LeftJoinModel {
|
||||||
|
@ -60,6 +68,7 @@ QObject {
|
||||||
id: writable
|
id: writable
|
||||||
|
|
||||||
sourceModel: joined
|
sourceModel: joined
|
||||||
|
visibilityHidden: Constants.ShowcaseVisibility.NoOne
|
||||||
}
|
}
|
||||||
|
|
||||||
SortFilterProxyModel {
|
SortFilterProxyModel {
|
||||||
|
@ -68,7 +77,7 @@ QObject {
|
||||||
sourceModel: writable
|
sourceModel: writable
|
||||||
delayed: true
|
delayed: true
|
||||||
|
|
||||||
filters: VisibilityFilter {}
|
filters: HiddenFilter { inverted: true }
|
||||||
sorters: RoleSorter { roleName: "position" }
|
sorters: RoleSorter { roleName: "position" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +87,6 @@ QObject {
|
||||||
sourceModel: writable
|
sourceModel: writable
|
||||||
delayed: true
|
delayed: true
|
||||||
|
|
||||||
filters: VisibilityFilter { inverted: true}
|
filters: HiddenFilter {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
QObject {
|
QObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
@ -106,20 +108,25 @@ QObject {
|
||||||
proxyRoles: FastExpressionRole {
|
proxyRoles: FastExpressionRole {
|
||||||
name: "maxVisibility"
|
name: "maxVisibility"
|
||||||
|
|
||||||
expression: {
|
// singletons cannot be used in expressions
|
||||||
const m = root.accountsVisibilityMap
|
readonly property int hidden: Constants.ShowcaseVisibility.NoOne
|
||||||
const accounts = model.accounts.split(":")
|
|
||||||
const visibilities = accounts.map(e => m[e]).filter(e => e)
|
|
||||||
|
|
||||||
return visibilities.length ? Math.min(...visibilities) : 0
|
expression: {
|
||||||
|
const visibilityMap = root.accountsVisibilityMap
|
||||||
|
const accounts = model.accounts.split(":")
|
||||||
|
const visibilities = accounts.map(a => visibilityMap[a]).filter(
|
||||||
|
v => v !== undefined)
|
||||||
|
|
||||||
|
return visibilities.length ? Math.min(...visibilities) : hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedRoles: ["accounts"]
|
expectedRoles: ["accounts"]
|
||||||
}
|
}
|
||||||
|
|
||||||
filters: RangeFilter {
|
filters: ValueFilter {
|
||||||
roleName: "maxVisibility"
|
roleName: "maxVisibility"
|
||||||
minimumValue: 1
|
value: Constants.ShowcaseVisibility.NoOne
|
||||||
|
inverted: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@ import StatusQ.Core.Utils 0.1
|
||||||
WritableProxyModel {
|
WritableProxyModel {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Hidden" is a special type of visibility that requires special
|
||||||
|
* treatment. When the visibility is changed from hidden to other type
|
||||||
|
* of visibility, in addition to changing the visibility, the appropriate
|
||||||
|
* position is also set.
|
||||||
|
*/
|
||||||
|
property int visibilityHidden: 0
|
||||||
|
|
||||||
/* Provides the list of objects representing the current state in the
|
/* Provides the list of objects representing the current state in the
|
||||||
* in the following format:
|
* in the following format:
|
||||||
* [ {
|
* [ {
|
||||||
|
@ -41,7 +49,8 @@ WritableProxyModel {
|
||||||
return
|
return
|
||||||
|
|
||||||
// hiding, changing visibility level
|
// hiding, changing visibility level
|
||||||
if (visibility === 0 || (visibility > 0 && oldVisibility > 0)) {
|
if (visibility === visibilityHidden
|
||||||
|
|| oldVisibility !== visibilityHidden) {
|
||||||
set(sourceIdx, { visibility: visibility })
|
set(sourceIdx, { visibility: visibility })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -96,11 +105,13 @@ WritableProxyModel {
|
||||||
const roles = ["key", "position", "visibility"]
|
const roles = ["key", "position", "visibility"]
|
||||||
const keysAndPos = ModelUtils.modelToArray(root, roles)
|
const keysAndPos = ModelUtils.modelToArray(root, roles)
|
||||||
|
|
||||||
return keysAndPos.filter(p => p.visibility)
|
return keysAndPos.filter(p => p.visibility
|
||||||
|
&& p.visibility !== root.visibilityHidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVisibility(idx) {
|
function getVisibility(idx) {
|
||||||
return ModelUtils.get(root, idx, "visibility") || 0
|
return ModelUtils.get(root, idx, "visibility")
|
||||||
|
|| root.visibilityHidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue