Merge branch 'feature/parse' into 'develop'

fixes

See merge request BPHV_MIPS/mvm_core_ui!265
This commit is contained in:
Suresh, Kamlesh Jain 2020-02-18 16:53:51 -05:00
commit ca20bd62ce
8 changed files with 43 additions and 21 deletions

View File

@ -8,12 +8,21 @@
import UIKit
class LabelAttributeActionModel: LabelAttributeModel {
open class LabelAttributeActionModel: LabelAttributeModel {
override public class var identifier: String {
return "action"
}
var action: ActionModelProtocol
public init(_ location: Int, _ length: Int, action: ActionModelProtocol) {
self.action = action
super.init(location, length)
}
private enum CodingKeys: String, CodingKey {
case action
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
@ -25,8 +34,4 @@ class LabelAttributeActionModel: LabelAttributeModel {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModel(action, forKey: .action)
}
private enum CodingKeys: String, CodingKey {
case action
}
}

View File

@ -25,12 +25,14 @@ import Foundation
return ""
}
var type: String
var type: String {
get { return Self.identifier }
}
var location: Int
var length: Int
init(_ type: String, _ location: Int, _ length: Int) {
self.type = type
init(_ location: Int, _ length: Int) {
self.location = location
self.length = length
}
@ -51,7 +53,6 @@ import Foundation
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
type = try typeContainer.decode(String.self, forKey: .type)
location = try typeContainer.decode(Int.self, forKey: .location)
length = try typeContainer.decode(Int.self, forKey: .length)
}

View File

@ -37,7 +37,3 @@ extension MFViewController: MoleculeDelegateProtocol {
@objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { }
}
public extension MFViewController {
@objc func parsePageJSON() throws { }
}

View File

@ -96,6 +96,9 @@
// This view controller should subclass this function and check the load to make sure it has all the needed data. Fills the error object if there are any errors. Returns if we should finish the load or not.
- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error;
/// Called in newDataBuildScreen. Can override to parse the json into a model object.
- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error;
// Sets the screen to use the screen heading.
// it is required in device flow, where we are showing greeting name as screen heading,
// device details screen heading needs to be updated/refreshed again, if user has changed device nick name

View File

@ -98,7 +98,7 @@
self.loadObject = loadObject;
NSError *parseError = nil;
[self parsePageJSONAndReturnError:&parseError];
[self parsePageJSON:&parseError];
if (parseError) {
if (error) {
MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
@ -112,6 +112,10 @@
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
}
- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error {
}
// Sets the screen to use the screen heading.
// it is required in device flow, where we are showing greeting name as screen heading,
// device details screen heading needs to be updated/refreshed again, if user has changed device nick name
@ -261,7 +265,7 @@
- (BOOL)newPageLoaded:(nonnull NSDictionary *)page {
self.loadObject.pageJSON = page;
NSError *parseError = nil;
[self parsePageJSONAndReturnError:&parseError];
[self parsePageJSON:&parseError];
return YES;
}

View File

@ -23,8 +23,12 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
// MARK: - Computed Properties
//--------------------------------------------------
@objc public override func parsePageJSON() throws {
try parseTemplateJSON()
open override func parsePageJSON(_ error: NSErrorPointer) {
do {
try parseTemplateJSON()
} catch let parseError {
error?.pointee = parseError as NSError
}
}
open override var loadObject: MVMCoreLoadObject? {

View File

@ -12,8 +12,12 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
var observer: NSKeyValueObservation?
public var templateModel: StackPageTemplateModel?
public override func parsePageJSON() throws {
try parseTemplateJSON()
open override func parsePageJSON(_ error: NSErrorPointer) {
do {
try parseTemplateJSON()
} catch let parseError {
error?.pointee = parseError as NSError
}
}
open override var loadObject: MVMCoreLoadObject? {

View File

@ -11,8 +11,13 @@ import UIKit
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
public var templateModel: ThreeLayerPageTemplateModel?
@objc public override func parsePageJSON() throws {
try parseTemplateJSON()
open override func parsePageJSON(_ error: NSErrorPointer) {
do {
try parseTemplateJSON()
} catch let parseError {
error?.pointee = parseError as NSError
}
}
override open func viewDidLoad() {