Fix id of Items, saving
This commit is contained in:
@ -20,7 +20,7 @@ final class InsertableFileButton: ObservableObject {
|
||||
"""
|
||||
icon: \(label.icon.rawValue)
|
||||
text: \(label.value)
|
||||
file: \(file.id)
|
||||
file: \(file.identifier)
|
||||
"""
|
||||
guard let downloadedFileName else {
|
||||
return result
|
||||
@ -86,7 +86,7 @@ struct InsertableButtons: View, InsertableCommandView {
|
||||
var id: String {
|
||||
switch self {
|
||||
case .file(let file):
|
||||
return "file-\(file.file?.id ?? "none")"
|
||||
return "file-\(file.file?.identifier ?? "none")"
|
||||
case .url(let url):
|
||||
return "url-\(url.url)"
|
||||
case .event(let event):
|
||||
@ -161,7 +161,7 @@ private struct FileButtonView: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
LabelEditingView(label: $content.label)
|
||||
Button("\(content.file?.id ?? "Select file")", action: { showFileSelectionSheet = true })
|
||||
Button("\(content.file?.identifier ?? "Select file")", action: { showFileSelectionSheet = true })
|
||||
OptionalTextField("", text: $content.downloadedFileName, prompt: "Downloaded file name")
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ struct InsertableGallery: View, InsertableCommandView {
|
||||
}
|
||||
return (
|
||||
["```\(GalleryBlock.blockId)"] +
|
||||
images.map { $0.id } +
|
||||
images.map { $0.identifier } +
|
||||
["```"]
|
||||
).joined(separator: "\n")
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ struct InsertableImage: View, InsertableCommandView {
|
||||
return nil
|
||||
}
|
||||
guard let caption else {
|
||||
return ")"
|
||||
return ")"
|
||||
}
|
||||
return ";\(caption))"
|
||||
return ";\(caption))"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,11 @@ struct InsertableLink: View, InsertableCommandView {
|
||||
case .post, .tagOverview:
|
||||
return nil
|
||||
case .page:
|
||||
return selectedPage?.id
|
||||
return selectedPage?.identifier
|
||||
case .tag:
|
||||
return selectedTag?.id
|
||||
return selectedTag?.identifier
|
||||
case .file:
|
||||
return selectedFile?.id
|
||||
return selectedFile?.identifier
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ struct InsertableRoute: View, InsertableCommandView {
|
||||
return nil
|
||||
}
|
||||
var result = ["```route"]
|
||||
result.append("\(RouteBlock.Key.image.rawValue): \(selectedImage.id)")
|
||||
result.append("\(RouteBlock.Key.file.rawValue): \(dataFile.id)")
|
||||
result.append("\(RouteBlock.Key.image.rawValue): \(selectedImage.identifier)")
|
||||
result.append("\(RouteBlock.Key.file.rawValue): \(dataFile.identifier)")
|
||||
if components != Set(RouteStatisticType.allCases) {
|
||||
let list = components
|
||||
.map { $0.rawValue }
|
||||
|
@ -50,16 +50,16 @@ struct InsertableVideo: View, InsertableCommandView {
|
||||
var lines: [String] = []
|
||||
lines.append("```video")
|
||||
if let posterImage {
|
||||
lines.append("\(VideoBlock.Key.poster): \(posterImage.id)")
|
||||
lines.append("\(VideoBlock.Key.poster): \(posterImage.identifier)")
|
||||
}
|
||||
if let videoH265 {
|
||||
lines.append("\(VideoBlock.Key.h265): \(videoH265.id)")
|
||||
lines.append("\(VideoBlock.Key.h265): \(videoH265.identifier)")
|
||||
}
|
||||
if let videoH264 {
|
||||
lines.append("\(VideoBlock.Key.h264): \(videoH264.id)")
|
||||
lines.append("\(VideoBlock.Key.h264): \(videoH264.identifier)")
|
||||
}
|
||||
if let videoWebm {
|
||||
lines.append("\(VideoBlock.Key.webm): \(videoWebm.id)")
|
||||
lines.append("\(VideoBlock.Key.webm): \(videoWebm.identifier)")
|
||||
}
|
||||
if controls { lines.append(VideoBlock.Key.controls.rawValue) }
|
||||
if autoplay { lines.append(VideoBlock.Key.autoplay.rawValue) }
|
||||
|
@ -35,7 +35,7 @@ struct PageContentResultsView: View {
|
||||
TextWithSymbol(
|
||||
symbol: $0.type.category.symbol,
|
||||
color: .blue,
|
||||
text: $0.id)
|
||||
text: $0.identifier)
|
||||
}
|
||||
+ results.missingFiles.keys.map {
|
||||
TextWithSymbol(
|
||||
|
@ -32,7 +32,7 @@ struct PageContentView: View {
|
||||
if page.isExternalUrl {
|
||||
VStack {
|
||||
PageTitleView(page: page.localized(in: language))
|
||||
.id(page.id + language.rawValue)
|
||||
.id(page.identifier + language.rawValue)
|
||||
Spacer()
|
||||
Text("No content available for external page")
|
||||
.font(.title)
|
||||
@ -42,10 +42,10 @@ struct PageContentView: View {
|
||||
} else {
|
||||
VStack(alignment: .leading) {
|
||||
PageTitleView(page: page.localized(in: language))
|
||||
.id(page.id + language.rawValue)
|
||||
.id(page.identifier + language.rawValue)
|
||||
TagDisplayView(tags: $page.tags)
|
||||
LocalizedPageContentView(page: page, language: language)
|
||||
.id(page.id + language.rawValue)
|
||||
.id(page.identifier + language.rawValue)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ struct PageDetailView: View {
|
||||
title: "Page",
|
||||
text: "A page contains longer content")
|
||||
IdPropertyView(
|
||||
id: $page.id,
|
||||
id: $page.identifier,
|
||||
footer: "The page id is used to link to it internally.",
|
||||
validation: page.isValid,
|
||||
update: { page.update(id: $0) })
|
||||
@ -75,7 +75,7 @@ struct PageDetailView: View {
|
||||
isExternalPage: page.isExternalUrl,
|
||||
page: page.localized(in: language),
|
||||
transferImage: transferImage)
|
||||
.id(page.id + language.rawValue)
|
||||
.id(page.identifier + language.rawValue)
|
||||
ColoredButton(delete: deletePage)
|
||||
}
|
||||
.padding()
|
||||
@ -83,8 +83,8 @@ struct PageDetailView: View {
|
||||
}
|
||||
|
||||
private func deletePage() {
|
||||
guard content.storage.delete(page: page.id) else {
|
||||
print("Page '\(page.id)': Failed to delete file in content folder")
|
||||
guard content.storage.delete(page: page.identifier) else {
|
||||
print("Page '\(page.identifier)': Failed to delete file in content folder")
|
||||
return
|
||||
}
|
||||
content.remove(page)
|
||||
|
Reference in New Issue
Block a user