This file contains 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
Ember.EditController = Ember.Mixin.create( | |
saveError: false | |
saveInvalid: false | |
isEditing: false | |
# Set associations to be associations of the content. These will then be checked for validity on save | |
# and all of the flags, such as isDirty and isLoaded, will take these associations into consideration. | |
# | |
# Eg: A user may have an address model which is edited within the same transaction. | |
# In this case you would put: |
This file contains 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
extension String { | |
public func splitLastWhitespace(after offset: Int) -> [Substring] { | |
guard let lastWS = self.prefix(offset).lastIndex(where: \.isWhitespace) else { | |
return [self[self.startIndex...]] | |
} | |
let first = self[self.startIndex..<lastWS] | |
let nextIndex = self.index(after: lastWS) | |
guard nextIndex != self.endIndex else { return [first] } | |
return [first, self[nextIndex...]] | |
} |