Merge branch 'feature/parse' into 'develop'
fixes See merge request BPHV_MIPS/mvm_core_ui!265
This commit is contained in:
commit
ca20bd62ce
@ -8,12 +8,21 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class LabelAttributeActionModel: LabelAttributeModel {
|
open class LabelAttributeActionModel: LabelAttributeModel {
|
||||||
override public class var identifier: String {
|
override public class var identifier: String {
|
||||||
return "action"
|
return "action"
|
||||||
}
|
}
|
||||||
var action: ActionModelProtocol
|
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 {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||||
@ -25,8 +34,4 @@ class LabelAttributeActionModel: LabelAttributeModel {
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeModel(action, forKey: .action)
|
try container.encodeModel(action, forKey: .action)
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
|
||||||
case action
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,14 @@ import Foundation
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var type: String
|
var type: String {
|
||||||
|
get { return Self.identifier }
|
||||||
|
}
|
||||||
|
|
||||||
var location: Int
|
var location: Int
|
||||||
var length: Int
|
var length: Int
|
||||||
|
|
||||||
init(_ type: String, _ location: Int, _ length: Int) {
|
init(_ location: Int, _ length: Int) {
|
||||||
self.type = type
|
|
||||||
self.location = location
|
self.location = location
|
||||||
self.length = length
|
self.length = length
|
||||||
}
|
}
|
||||||
@ -51,7 +53,6 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
type = try typeContainer.decode(String.self, forKey: .type)
|
|
||||||
location = try typeContainer.decode(Int.self, forKey: .location)
|
location = try typeContainer.decode(Int.self, forKey: .location)
|
||||||
length = try typeContainer.decode(Int.self, forKey: .length)
|
length = try typeContainer.decode(Int.self, forKey: .length)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,3 @@ extension MFViewController: MoleculeDelegateProtocol {
|
|||||||
|
|
||||||
@objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { }
|
@objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension MFViewController {
|
|
||||||
@objc func parsePageJSON() throws { }
|
|
||||||
}
|
|
||||||
|
|||||||
@ -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.
|
// 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;
|
- (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.
|
// Sets the screen to use the screen heading.
|
||||||
// it is required in device flow, where we are showing greeting name as 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
|
// device details screen heading needs to be updated/refreshed again, if user has changed device nick name
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
self.loadObject = loadObject;
|
self.loadObject = loadObject;
|
||||||
|
|
||||||
NSError *parseError = nil;
|
NSError *parseError = nil;
|
||||||
[self parsePageJSONAndReturnError:&parseError];
|
[self parsePageJSON:&parseError];
|
||||||
if (parseError) {
|
if (parseError) {
|
||||||
if (error) {
|
if (error) {
|
||||||
MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
|
MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
|
||||||
@ -112,6 +112,10 @@
|
|||||||
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
|
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Sets the screen to use the screen heading.
|
// Sets the screen to use the screen heading.
|
||||||
// it is required in device flow, where we are showing greeting name as 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
|
// 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 {
|
- (BOOL)newPageLoaded:(nonnull NSDictionary *)page {
|
||||||
self.loadObject.pageJSON = page;
|
self.loadObject.pageJSON = page;
|
||||||
NSError *parseError = nil;
|
NSError *parseError = nil;
|
||||||
[self parsePageJSONAndReturnError:&parseError];
|
[self parsePageJSON:&parseError];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,12 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
@objc public override func parsePageJSON() throws {
|
open override func parsePageJSON(_ error: NSErrorPointer) {
|
||||||
try parseTemplateJSON()
|
do {
|
||||||
|
try parseTemplateJSON()
|
||||||
|
} catch let parseError {
|
||||||
|
error?.pointee = parseError as NSError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var loadObject: MVMCoreLoadObject? {
|
open override var loadObject: MVMCoreLoadObject? {
|
||||||
|
|||||||
@ -12,8 +12,12 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
|||||||
|
|
||||||
var observer: NSKeyValueObservation?
|
var observer: NSKeyValueObservation?
|
||||||
public var templateModel: StackPageTemplateModel?
|
public var templateModel: StackPageTemplateModel?
|
||||||
public override func parsePageJSON() throws {
|
open override func parsePageJSON(_ error: NSErrorPointer) {
|
||||||
try parseTemplateJSON()
|
do {
|
||||||
|
try parseTemplateJSON()
|
||||||
|
} catch let parseError {
|
||||||
|
error?.pointee = parseError as NSError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var loadObject: MVMCoreLoadObject? {
|
open override var loadObject: MVMCoreLoadObject? {
|
||||||
|
|||||||
@ -11,8 +11,13 @@ import UIKit
|
|||||||
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||||
|
|
||||||
public var templateModel: ThreeLayerPageTemplateModel?
|
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() {
|
override open func viewDidLoad() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user