-
Notifications
You must be signed in to change notification settings - Fork 121
Shipping Labels: Add new entities for WooShippingShipment and Item #15897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48c1700
Add new model version 124
itsmeichigo 87b1f26
Add new WooShippingShipment and WooShippingShipmentItem entities
itsmeichigo 987e878
Add migration test
itsmeichigo f8b4952
Add readonly convertible for new entities
itsmeichigo 44e1815
Add relationship between order and shipments
itsmeichigo 9b9cb15
Update MIGRATIONS note
itsmeichigo 8099620
Remove extra line
itsmeichigo 91f1d8b
Keep shipment index non-optional
itsmeichigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Modules/Sources/Storage/Model/WooShippingShipment+CoreDataClass.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Foundation | ||
| import CoreData | ||
|
|
||
| @objc(WooShippingShipment) | ||
| public class WooShippingShipment: NSManagedObject { | ||
|
|
||
| } |
33 changes: 33 additions & 0 deletions
33
Modules/Sources/Storage/Model/WooShippingShipment+CoreDataProperties.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import Foundation | ||
| import CoreData | ||
|
|
||
| extension WooShippingShipment { | ||
| @nonobjc public class func fetchRequest() -> NSFetchRequest<WooShippingShipment> { | ||
| return NSFetchRequest<WooShippingShipment>(entityName: "WooShippingShipment") | ||
| } | ||
|
|
||
| @NSManaged public var siteID: Int64 | ||
| @NSManaged public var orderID: Int64 | ||
| @NSManaged public var index: String | ||
| @NSManaged public var shippingLabel: ShippingLabel? | ||
| @NSManaged public var items: Set<WooShippingShipmentItem>? | ||
| @NSManaged public var order: Order? | ||
|
|
||
| } | ||
|
|
||
| // MARK: Generated accessors for items | ||
| extension WooShippingShipment { | ||
|
|
||
| @objc(addItemsObject:) | ||
| @NSManaged public func addToItems(_ value: WooShippingShipmentItem) | ||
|
|
||
| @objc(removeItemsObject:) | ||
| @NSManaged public func removeFromItems(_ value: WooShippingShipmentItem) | ||
|
|
||
| @objc(addItems:) | ||
| @NSManaged public func addToItems(_ values: NSSet) | ||
|
|
||
| @objc(removeItems:) | ||
| @NSManaged public func removeFromItems(_ values: NSSet) | ||
|
|
||
| } | ||
7 changes: 7 additions & 0 deletions
7
Modules/Sources/Storage/Model/WooShippingShipmentItem+CoreDataClass.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Foundation | ||
| import CoreData | ||
|
|
||
| @objc(WooShippingShipmentItem) | ||
| public class WooShippingShipmentItem: NSManagedObject { | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
Modules/Sources/Storage/Model/WooShippingShipmentItem+CoreDataProperties.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import Foundation | ||
| import CoreData | ||
|
|
||
| extension WooShippingShipmentItem { | ||
|
|
||
| @nonobjc public class func fetchRequest() -> NSFetchRequest<WooShippingShipmentItem> { | ||
| return NSFetchRequest<WooShippingShipmentItem>(entityName: "WooShippingShipmentItem") | ||
| } | ||
|
|
||
| @NSManaged public var id: Int64 | ||
| @NSManaged public var subItems: NSArray? | ||
| @NSManaged public var shipment: WooShippingShipment? | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,085 changes: 1,085 additions & 0 deletions
1,085
Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/Model 124.xcdatamodel/contents
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Modules/Sources/Yosemite/Model/Storage/WooShippingShipment+ReadOnlyConvertible.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import Foundation | ||
| import Storage | ||
|
|
||
| // Storage.WooShippingShipment: ReadOnlyConvertible Conformance. | ||
| // | ||
| extension Storage.WooShippingShipment: ReadOnlyConvertible { | ||
| /// Updates the Storage.WooShippingShipment with the a ReadOnly WooShippingShipment. | ||
| /// | ||
| public func update(with savedShipment: Yosemite.WooShippingShipment) { | ||
| self.siteID = savedShipment.siteID | ||
| self.orderID = savedShipment.orderID | ||
| self.index = savedShipment.index | ||
| } | ||
|
|
||
| /// Returns a ReadOnly version of the receiver. | ||
| /// | ||
| public func toReadOnly() -> Yosemite.WooShippingShipment { | ||
| let shipmentShippingLabel = shippingLabel?.toReadOnly() | ||
| let shipmentItems = items?.map { $0.toReadOnly() } ?? [Yosemite.WooShippingShipmentItem]() | ||
|
|
||
| return WooShippingShipment(siteID: siteID, | ||
| orderID: orderID, | ||
| index: index, | ||
| items: shipmentItems, | ||
| shippingLabel: shipmentShippingLabel) | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
Modules/Sources/Yosemite/Model/Storage/WooShippingShipmentItem+ReadOnlyConvertible.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import Foundation | ||
| import Storage | ||
|
|
||
| // Storage.WooShippingShipmentItem: ReadOnlyConvertible Conformance. | ||
| // | ||
| extension Storage.WooShippingShipmentItem: ReadOnlyConvertible { | ||
| /// Updates the Storage.WooShippingShipmentItem with the a ReadOnly WooShippingShipmentItem. | ||
| /// | ||
| public func update(with savedItem: Yosemite.WooShippingShipmentItem) { | ||
| self.id = savedItem.id | ||
| self.subItems = savedItem.subItems as? NSArray | ||
| } | ||
|
|
||
| /// Returns a ReadOnly version of the receiver. | ||
| /// | ||
| public func toReadOnly() -> Yosemite.WooShippingShipmentItem { | ||
| WooShippingShipmentItem(id: id, subItems: subItems as? [String]) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to also store
siteIDandorderIDhere since those are accessible throughorderrelationship?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
orderrelationship is optional, so I'd prefer having non-optional IDs here instead.