C8yEditableGroup

public class C8yEditableGroup : ObservableObject

Use this class directly from a SwiftUI Form View to allow the wrapped group to be edited.

Changes to fields are published to the attribute onChange and can be acted on in your View with the following code. Duplicates are removed and changes are debounced into 1 event every 3 seconds, this means you could automatically persist changes to Cumulocity via the method C8yAssetCollection.saveObject(_) without having it called on each key press made by the user.

VStack {
    ...
}.onReceive(self.editableGroup.onChange) { editableGroup in

    do {
        try self.assetCollection.saveObject(editableGroup.toGroup()) { success, error in

        }
    } catch {
        print("error \(error.localizedDescription)")
    }
}
  • Undocumented

    Declaration

    Swift

    public static let GROUP_ID_TYPE: String
  • Undocumented

    Declaration

    Swift

    @Published
    public var c8yId: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var externalId: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var name: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var category: C8yGroupCategory { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var orgName: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var contactPerson: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var contactEmail: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var contactPhone: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var addressLine1: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var addressLine2: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var city: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var postCode: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var country: String { get set }
  • Undocumented

    Declaration

    Swift

    @Published
    public var notes: String { get set }
  • lat

    Undocumented

    Declaration

    Swift

    @Published
    public var lat: Double { get set }
  • lng

    Undocumented

    Declaration

    Swift

    @Published
    public var lng: Double { get set }
  • alt

    Undocumented

    Declaration

    Swift

    @Published
    public var alt: Double { get set }
  • Undocumented

    Declaration

    Swift

    public var isNew: Bool { get }
  • true if changes have been made to any of the attributes, you will need to set it back to false explicitly once changed e.g. after saving changes via the onChange publisher

    Declaration

    Swift

    public var haveChanges: Bool
  • Undocumented

    Declaration

    Swift

    public var readyToDeploy: Bool { get }
  • Use this publisher to listen for changes to any of device attribute, removes duplicates and debounces to minimise events to maximum 1 every 3 seconds

    Declaration

    Swift

    public var onChange: AnyPublisher<C8yEditableGroup, Never> { get }
  • Undocumented

    Declaration

    Swift

    public init()
  • Constructor to allow an existing device to be edited.

    Declaration

    Swift

    public convenience init(withGroup group: C8yGroup)
  • Clears all of the editable fields without triggering change event publishers

    Declaration

    Swift

    public func clear()
  • Returns a C8yGroup instance with all of the edited fields included

    Declaration

    Swift

    public func toGroup(_ parentGroupName: String? = nil) -> C8yGroup
  • Undocumented

    Declaration

    Swift

    public func toGroup(_ originalGroup: C8yGroup) -> C8yGroup