diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 99b14870..2f856074 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -51,16 +51,16 @@ import UIKit super.updateView(size) dropDown?.updateView(size) } - -// // MARK: - MoleculeDelegateProtocol -// public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { -// bottomSeparatorView?.style = .none -// self.delegateObject = delegateObject -// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) -// dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate -// dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate -// dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) -// } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + bottomSeparatorView?.style = .none + self.delegateObject = delegateObject + super.setWithModel(model, delegateObject, additionalData) + + dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate + dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate + dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) + } public override func reset() { super.reset() diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index ffaefcb5..20c48487 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -176,7 +176,7 @@ import UIKit // override the separator if let separator = model.separator { addSeparatorsIfNeeded() - (bottomSeparatorView as? ModelMoleculeViewProtocol)?.setWithModel(separator, nil, nil) + bottomSeparatorView?.setWithModel(separator, nil, nil) } guard let moleculeModel = model.molecule else { return } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index fd1885cc..534d3228 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -160,14 +160,14 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality -// for molecule in molecules { -// if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in -// return molecule == moleculeInfo.molecule -// }) { -// moleculesInfo?.remove(at: removeIndex) -// indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) -// } -// } + for molecule in molecules { + if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + return molecule.toJSONString() == moleculeInfo.molecule.toJSONString() + }) { + moleculesInfo?.remove(at: removeIndex) + indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) + } + } self.tableView?.deleteRows(at: indexPaths, with: animation) self.updateViewConstraints() self.view.layoutIfNeeded()