removed id
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d6a2ebaf95
commit
3b3ea3bece
@ -58,9 +58,6 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType>, Changable
|
|||||||
|
|
||||||
public var onChange: Blocks.ActionBlock?
|
public var onChange: Blocks.ActionBlock?
|
||||||
|
|
||||||
@Proxy(\.model.id)
|
|
||||||
open var id: UUID
|
|
||||||
|
|
||||||
//can't bind to @Proxy
|
//can't bind to @Proxy
|
||||||
open override var isSelected: Bool {
|
open override var isSelected: Bool {
|
||||||
get { model.selected }
|
get { model.selected }
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public class CheckboxGroup: Control<DefaultCheckboxGroupModel>, SelectorGroupMod
|
|||||||
open override func updateView(viewModel: ModelType) {
|
open override func updateView(viewModel: ModelType) {
|
||||||
for selectorModel in viewModel.selectors {
|
for selectorModel in viewModel.selectors {
|
||||||
//see if view is there for the model
|
//see if view is there for the model
|
||||||
if let foundSelectorView = findSelectorView(id: selectorModel.id) {
|
if let foundSelectorView = findSelectorView(inputId: selectorModel.inputId) {
|
||||||
foundSelectorView.set(with: selectorModel)
|
foundSelectorView.set(with: selectorModel)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@ -7,13 +7,12 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public protocol CheckboxGroupModel: SelectorGroupModelable where SelectorModelType: CheckboxModel {
|
public protocol CheckboxGroupModel: SelectorGroupModelable, Errorable where SelectorModelType: CheckboxModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DefaultCheckboxGroupModel: CheckboxGroupModel {
|
public struct DefaultCheckboxGroupModel: CheckboxGroupModel {
|
||||||
public typealias SelectorModelType = DefaultCheckboxModel
|
public typealias SelectorModelType = DefaultCheckboxModel
|
||||||
public var id: UUID = UUID()
|
|
||||||
public var inputId: String?
|
public var inputId: String?
|
||||||
public var value: AnyHashable?
|
public var value: AnyHashable?
|
||||||
public var surface: Surface = .light
|
public var surface: Surface = .light
|
||||||
|
|||||||
@ -64,7 +64,6 @@ extension CheckboxModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct DefaultCheckboxModel: CheckboxModel {
|
public struct DefaultCheckboxModel: CheckboxModel {
|
||||||
public var id: UUID = UUID()
|
|
||||||
public var selected: Bool = false
|
public var selected: Bool = false
|
||||||
|
|
||||||
public var labelText: String?
|
public var labelText: String?
|
||||||
|
|||||||
@ -60,9 +60,6 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType>, Changable
|
|||||||
|
|
||||||
public var onChange: Blocks.ActionBlock?
|
public var onChange: Blocks.ActionBlock?
|
||||||
|
|
||||||
@Proxy(\.model.id)
|
|
||||||
open var id: UUID
|
|
||||||
|
|
||||||
//can't bind to @Proxy
|
//can't bind to @Proxy
|
||||||
open override var isSelected: Bool {
|
open override var isSelected: Bool {
|
||||||
get { model.selected }
|
get { model.selected }
|
||||||
|
|||||||
@ -117,7 +117,7 @@ public class RadioBoxGroup: Control<DefaultRadioBoxGroupModel>, SelectorGroupSel
|
|||||||
open override func updateView(viewModel: ModelType) {
|
open override func updateView(viewModel: ModelType) {
|
||||||
for selectorModel in viewModel.selectors {
|
for selectorModel in viewModel.selectors {
|
||||||
//see if view is there for the model
|
//see if view is there for the model
|
||||||
if let foundSelectorView = findSelectorView(id: selectorModel.id) {
|
if let foundSelectorView = findSelectorView(inputId: selectorModel.inputId) {
|
||||||
foundSelectorView.set(with: selectorModel)
|
foundSelectorView.set(with: selectorModel)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,6 @@ extension RadioBoxModel {
|
|||||||
|
|
||||||
public struct DefaultRadioBoxModel: RadioBoxModel {
|
public struct DefaultRadioBoxModel: RadioBoxModel {
|
||||||
|
|
||||||
public var id: UUID = UUID()
|
|
||||||
public var selected: Bool = false
|
public var selected: Bool = false
|
||||||
|
|
||||||
public var text: String = "Default Text"
|
public var text: String = "Default Text"
|
||||||
|
|||||||
@ -57,9 +57,6 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType>, Cha
|
|||||||
|
|
||||||
public var onChange: Blocks.ActionBlock?
|
public var onChange: Blocks.ActionBlock?
|
||||||
|
|
||||||
@Proxy(\.model.id)
|
|
||||||
open var id: UUID
|
|
||||||
|
|
||||||
//can't bind to @Proxy
|
//can't bind to @Proxy
|
||||||
open override var isSelected: Bool {
|
open override var isSelected: Bool {
|
||||||
get { model.selected }
|
get { model.selected }
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class RadioButtonGroup: Control<DefaultRadioButtonGroupModel>, SelectorGr
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func shouldUpdateView(viewModel: ModelType) -> Bool {
|
open override func shouldUpdateView(viewModel: ModelType) -> Bool {
|
||||||
let update = viewModel.selectedModel?.id != model.selectedModel?.id
|
let update = viewModel.selectedModel?.inputId != model.selectedModel?.inputId
|
||||||
|| viewModel.selectors.count != model.selectors.count
|
|| viewModel.selectors.count != model.selectors.count
|
||||||
|| viewModel.hasError != model.hasError
|
|| viewModel.hasError != model.hasError
|
||||||
|| viewModel.surface != model.surface
|
|| viewModel.surface != model.surface
|
||||||
@ -97,7 +97,7 @@ public class RadioButtonGroup: Control<DefaultRadioButtonGroupModel>, SelectorGr
|
|||||||
open override func updateView(viewModel: ModelType) {
|
open override func updateView(viewModel: ModelType) {
|
||||||
for selectorModel in viewModel.selectors {
|
for selectorModel in viewModel.selectors {
|
||||||
//see if view is there for the model
|
//see if view is there for the model
|
||||||
if let foundSelectorView = findSelectorView(id: selectorModel.id) {
|
if let foundSelectorView = findSelectorView(inputId: selectorModel.inputId) {
|
||||||
foundSelectorView.set(with: selectorModel)
|
foundSelectorView.set(with: selectorModel)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,6 @@ extension RadioButtonModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct DefaultRadioButtonModel: RadioButtonModel {
|
public struct DefaultRadioButtonModel: RadioButtonModel {
|
||||||
public var id: UUID = UUID()
|
|
||||||
public var selected: Bool = false
|
public var selected: Bool = false
|
||||||
|
|
||||||
public var labelText: String?
|
public var labelText: String?
|
||||||
|
|||||||
@ -30,7 +30,6 @@ extension ToggleModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct DefaultToggleModel: ToggleModel {
|
public struct DefaultToggleModel: ToggleModel {
|
||||||
public var id: UUID = UUID()
|
|
||||||
public var on: Bool = false
|
public var on: Bool = false
|
||||||
public var showText: Bool = false
|
public var showText: Bool = false
|
||||||
public var offText: String = "Off"
|
public var offText: String = "Off"
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public protocol FormFieldable {
|
public protocol FormFieldable {
|
||||||
var id: UUID { get set }
|
|
||||||
var inputId: String? { get set }
|
var inputId: String? { get set }
|
||||||
var value: AnyHashable? { get set }
|
var value: AnyHashable? { get set }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,9 @@ public protocol SelectorGroupModelHandlerable: ModelHandlerable, Disabling, Surf
|
|||||||
|
|
||||||
extension SelectorGroupModelHandlerable {
|
extension SelectorGroupModelHandlerable {
|
||||||
|
|
||||||
public func findSelectorView(id: UUID) -> ModelHandlerType? {
|
public func findSelectorView(inputId: String?) -> ModelHandlerType? {
|
||||||
return selectorViews.first(where: { existingSelectorView in
|
return selectorViews.first(where: { existingSelectorView in
|
||||||
return existingSelectorView.model.id == id
|
return existingSelectorView.model.inputId == inputId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ extension SelectorGroupModelHandlerable {
|
|||||||
|
|
||||||
public func getCachedSelector(viewModel: ModelHandlerType.ModelType) -> ModelHandlerType.ModelType? {
|
public func getCachedSelector(viewModel: ModelHandlerType.ModelType) -> ModelHandlerType.ModelType? {
|
||||||
if let index = model.selectors.firstIndex(where: { element in
|
if let index = model.selectors.firstIndex(where: { element in
|
||||||
return element.id == viewModel.id
|
return element.inputId == viewModel.inputId
|
||||||
}) {
|
}) {
|
||||||
return model.selectors[index]
|
return model.selectors[index]
|
||||||
} else {
|
} else {
|
||||||
@ -61,7 +61,7 @@ extension SelectorGroupModelHandlerable {
|
|||||||
|
|
||||||
public func replace(viewModel: ModelHandlerType.ModelType){
|
public func replace(viewModel: ModelHandlerType.ModelType){
|
||||||
if let index = model.selectors.firstIndex(where: { element in
|
if let index = model.selectors.firstIndex(where: { element in
|
||||||
return element.id == viewModel.id
|
return element.inputId == viewModel.inputId
|
||||||
}) {
|
}) {
|
||||||
model.selectors[index] = viewModel
|
model.selectors[index] = viewModel
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user