#722 - sub-content support

This commit is contained in:
Elio Struyf
2023-12-07 11:04:18 +01:00
parent f350d4af91
commit 78bfa62ed4
7 changed files with 104 additions and 3 deletions
+1
View File
@@ -17,6 +17,7 @@
- [#709](https://github.com/estruyf/vscode-front-matter/issues/709): Take "where clause" into account on content creation
- [#710](https://github.com/estruyf/vscode-front-matter/issues/710): Hide child field when parent field its "when clause" is not met, also remove the fields from the content
- [#713](https://github.com/estruyf/vscode-front-matter/issues/713): Add the ability to always use quotes around string values in front matter
- [#722](https://github.com/estruyf/vscode-front-matter/issues/722): Allow to create sub-content which shows a dialog to select the parent folder
### ⚡️ Optimizations
+6
View File
@@ -582,6 +582,12 @@
"helpers.contentType.setContentType.noFrontMatter.warning": "No front matter data found to set the content type.",
"helpers.contentType.setContentType.quickPick.title": "Select the content type",
"helpers.contentType.setContentType.quickPick.placeholder": "Which content type would you like to use?",
"helpers.contentType.create.allowSubContent.title": "Do you want to create it as sub-content?",
"helpers.contentType.create.allowSubContent.placeHolder": "Do you want to create it as sub-content?",
"helpers.contentType.create.allowSubContent.showOpenDialog.openLabel": "Select folder",
"helpers.contentType.create.allowSubContent.showOpenDialog.title": "Select folder to create the content",
"helpers.contentType.create.pageBundle.title": "Create as a page bundle?",
"helpers.contentType.create.pageBundle.placeHolder": "Do you want to create the sub-content as a page bundle?",
"helpers.contentType.create.progress.title": "{0}: Creating content...",
"helpers.contentType.create.success": "Your new content has been created.",
"helpers.contentType.verify.warning": "The content type actions are not available in this mode.",
+11 -1
View File
@@ -1074,7 +1074,17 @@
"clearEmpty": {
"type": "boolean",
"default": false,
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.clearEmpty.description%"
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.clearEmpty.description%"
},
"allowAsSubContent": {
"type": "boolean",
"default": false,
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.allowAsSubContent.description%"
},
"isSubContent": {
"type": "boolean",
"default": false,
"description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.isSubContent.description%"
},
"fields": {
"$id": "#contenttypefield",
+4 -2
View File
@@ -245,8 +245,10 @@
"setting.frontMatter.taxonomy.dateField.deprecationMessage": "This setting is deprecated and will be removed in the next major version. Please use the new `isPublishDate` settings instead in your content types date fields.",
"setting.frontMatter.taxonomy.modifiedField.deprecationMessage": "This setting is deprecated and will be removed in the next major version. Please use the new `isModifiedDate` settings instead in your content types date fields.",
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.customType.description": "Specify the name of the custom field type to use.",
"setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.clearEmpty.description": "Specify if the empty values should be cleared.",
"setting.frontMatter.taxonomy.contentTypes.items.properties.clearEmpty.description": "Specify if the empty values should be cleared.",
"setting.frontMatter.website.host.markdownDescription": "Specify the host URL of your website. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.website.url)",
"command.frontMatter.settings.refresh": "Refresh Front Matter Settings",
"setting.frontMatter.config.dynamicFilePath.markdownDescription": "Specify the path to the dynamic config file (ex: [[workspace]]/config.js). [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.config.dynamicfilepath)"
"setting.frontMatter.config.dynamicFilePath.markdownDescription": "Specify the path to the dynamic config file (ex: [[workspace]]/config.js). [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.config.dynamicfilepath)",
"setting.frontMatter.taxonomy.contentTypes.items.properties.allowAsSubContent.description": "Specify if the content type can be used as sub content.",
"setting.frontMatter.taxonomy.contentTypes.items.properties.isSubContent.description": "Specify if the content type is sub content."
}
+56
View File
@@ -814,6 +814,62 @@ export class ContentType {
cancellable: false
},
async () => {
if (contentType.isSubContent || contentType.allowAsSubContent) {
let showDialog = true;
if (contentType.allowAsSubContent) {
const subContentAnswer = await window.showQuickPick(
[l10n.t(LocalizationKey.commonNo), l10n.t(LocalizationKey.commonYes)],
{
title: l10n.t(LocalizationKey.helpersContentTypeCreateAllowSubContentTitle),
placeHolder: l10n.t(
LocalizationKey.helpersContentTypeCreateAllowSubContentPlaceHolder
),
ignoreFocusOut: true
}
);
showDialog = subContentAnswer === l10n.t(LocalizationKey.commonYes);
}
if (showDialog) {
const folderLocation = await window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
defaultUri: Uri.file(folderPath),
openLabel: l10n.t(
LocalizationKey.helpersContentTypeCreateAllowSubContentShowOpenDialogOpenLabel
),
title: l10n.t(
LocalizationKey.helpersContentTypeCreateAllowSubContentShowOpenDialogTitle
)
});
if (!folderLocation || folderLocation.length === 0) {
return;
}
folderPath = folderLocation[0].fsPath;
if (contentType.pageBundle) {
const createAsPageBundle = await window.showQuickPick(
[l10n.t(LocalizationKey.commonNo), l10n.t(LocalizationKey.commonYes)],
{
title: l10n.t(LocalizationKey.helpersContentTypeCreatePageBundleTitle),
placeHolder: l10n.t(
LocalizationKey.helpersContentTypeCreatePageBundlePlaceHolder
),
ignoreFocusOut: true
}
);
if (createAsPageBundle === l10n.t(LocalizationKey.commonNo)) {
contentType.pageBundle = false;
}
}
}
}
let titleValue = await Questions.ContentTitle();
if (!titleValue) {
return;
+24
View File
@@ -1896,6 +1896,30 @@ export enum LocalizationKey {
* Which content type would you like to use?
*/
helpersContentTypeSetContentTypeQuickPickPlaceholder = 'helpers.contentType.setContentType.quickPick.placeholder',
/**
* Do you want to create it as sub-content?
*/
helpersContentTypeCreateAllowSubContentTitle = 'helpers.contentType.create.allowSubContent.title',
/**
* Do you want to create it as sub-content?
*/
helpersContentTypeCreateAllowSubContentPlaceHolder = 'helpers.contentType.create.allowSubContent.placeHolder',
/**
* Select folder
*/
helpersContentTypeCreateAllowSubContentShowOpenDialogOpenLabel = 'helpers.contentType.create.allowSubContent.showOpenDialog.openLabel',
/**
* Select folder to create the content
*/
helpersContentTypeCreateAllowSubContentShowOpenDialogTitle = 'helpers.contentType.create.allowSubContent.showOpenDialog.title',
/**
* Create as a page bundle?
*/
helpersContentTypeCreatePageBundleTitle = 'helpers.contentType.create.pageBundle.title',
/**
* Do you want to create the sub-content as a page bundle?
*/
helpersContentTypeCreatePageBundlePlaceHolder = 'helpers.contentType.create.pageBundle.placeHolder',
/**
* {0}: Creating content...
*/
+2
View File
@@ -65,6 +65,8 @@ export interface ContentType {
postScript?: string;
filePrefix?: string;
clearEmpty?: boolean;
isSubContent?: boolean;
allowAsSubContent?: boolean;
}
export type FieldType =