Compare commits
2 Commits
6d33265a01
...
2167de1672
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2167de1672 | ||
|
|
ef64310b51 |
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '62bbe4b1522ccd65faf8');
|
||||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'fcd901559e8b72a56c33');
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/*!****************************************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** css ../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!../../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!../../node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/editor.scss ***!
|
||||
\****************************************************************************************************************************************************************************************************************************************************/
|
||||
/**
|
||||
* The following styles get applied inside the editor only.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
.wp-block-create-block-test {
|
||||
border: 1px dotted #f00;
|
||||
.homegrade-blocks-parcours-step.is-selected {
|
||||
outline: 2px solid var(--wp--preset--color--secondary, --wp-admin-theme-color, #007cba) !important;
|
||||
}
|
||||
.homegrade-blocks-parcours-step.is-selected:focus:after {
|
||||
position: static !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=index.css.map*/
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.css","mappings":";;;AAAA;;;;EAAA;AAMA;EACC;AAAD,C","sources":["webpack://test/./src/editor.scss"],"sourcesContent":["/**\n * The following styles get applied inside the editor only.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.wp-block-create-block-test {\n\tborder: 1px dotted #f00;\n}\n"],"names":[],"sourceRoot":""}
|
||||
{"version":3,"file":"index.css","mappings":";;;AAAA;EACC;AACD;AAAC;EACC;EACA;AAEF,C","sources":["webpack://test/./src/editor.scss"],"sourcesContent":[".homegrade-blocks-parcours-step.is-selected {\n\toutline: 2px solid var(--wp--preset--color--secondary, --wp-admin-theme-color, #007cba) !important;\n\t&:focus:after {\n\t\tposition: static !important;\n\t\toutline: none !important;\n\t}\n}\n"],"names":[],"sourceRoot":""}
|
||||
|
|
@ -41,14 +41,14 @@ function OptionsSelectControl({
|
|||
relatedPostId
|
||||
}) {
|
||||
let [postOptions, setPostOptions] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
|
||||
const lang = (0,_utilities_js__WEBPACK_IMPORTED_MODULE_5__.getAdminLanguageFromCookie)("wp-wpml_current_language");
|
||||
const lang = (0,_utilities_js__WEBPACK_IMPORTED_MODULE_5__.getAdminLanguageFromCookie)('wp-wpml_current_language');
|
||||
const optionPages = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_6__.useSelect)(select => {
|
||||
let query = {
|
||||
status: "publish",
|
||||
status: ['draft', 'publish'],
|
||||
per_page: -1,
|
||||
lang: lang
|
||||
};
|
||||
return select("core").getEntityRecords("postType", "parcours", query);
|
||||
return select('core').getEntityRecords('postType', 'parcours', query);
|
||||
}, [lang]);
|
||||
const editUrl = relatedPostId ? `${window.location.origin}/wp-admin/post.php?post=${relatedPostId}&action=edit` : null;
|
||||
function handleRelatedPostChange(postId) {
|
||||
|
|
@ -61,7 +61,7 @@ function OptionsSelectControl({
|
|||
if (optionPages && optionPages.length > 0) {
|
||||
options.push({
|
||||
value: 0,
|
||||
label: "Selectionnez une page"
|
||||
label: 'Selectionnez une page'
|
||||
});
|
||||
optionPages.forEach(page => {
|
||||
options.push({
|
||||
|
|
@ -72,7 +72,7 @@ function OptionsSelectControl({
|
|||
} else {
|
||||
options.push({
|
||||
value: 0,
|
||||
label: "Pas encore de questions..."
|
||||
label: 'Pas encore de questions...'
|
||||
});
|
||||
}
|
||||
return options;
|
||||
|
|
@ -83,15 +83,15 @@ function OptionsSelectControl({
|
|||
setPostOptions(buildSelectOptions(optionPages));
|
||||
}
|
||||
}, [optionPages]);
|
||||
let panelTitle = "Post Parcours Reliée";
|
||||
let panelTitle = 'Post Parcours Reliée';
|
||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.PanelBody, {
|
||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Étape parcours", "homegrade-blocks")
|
||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Étape parcours', 'homegrade-blocks')
|
||||
}, postOptions && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.ComboboxControl, {
|
||||
label: panelTitle,
|
||||
value: relatedPostId,
|
||||
options: postOptions,
|
||||
onChange: e => handleRelatedPostChange(e)
|
||||
}), relatedPostId && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Tip, null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.", "homegrade-blocks")), relatedPostId && editUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", {
|
||||
}), relatedPostId && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Tip, null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.', 'homegrade-blocks')), relatedPostId && editUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", {
|
||||
href: editUrl,
|
||||
className: "edit-question-button"
|
||||
}, "\xC9diter le post")));
|
||||
|
|
@ -132,11 +132,11 @@ function Edit({
|
|||
const {
|
||||
relatedPostId
|
||||
} = attributes;
|
||||
const post = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select("core").getEntityRecord("postType", "parcours", relatedPostId));
|
||||
const post = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => select('core').getEntityRecord('postType', 'parcours', relatedPostId));
|
||||
const stepIconUrl = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_4__.useSelect)(select => {
|
||||
var _media$source_url;
|
||||
let setpIconID = post?.acf?.step_icon;
|
||||
const media = select("core").getMedia(setpIconID);
|
||||
const media = select('core').getMedia(setpIconID);
|
||||
return (_media$source_url = media?.source_url) !== null && _media$source_url !== void 0 ? _media$source_url : null;
|
||||
}, [post]);
|
||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_OptionsSelectControl__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
||||
|
|
@ -147,7 +147,7 @@ function Edit({
|
|||
className: `homegrade-blocks-parcours-step parcours-step parcours-step-card`
|
||||
})
|
||||
}, post && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||
class: "parcours-step-card__icon",
|
||||
className: "parcours-step-card__icon",
|
||||
src: stepIconUrl,
|
||||
alt: ""
|
||||
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,29 +1,25 @@
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import { InspectorControls } from "@wordpress/block-editor";
|
||||
import {
|
||||
PanelBody,
|
||||
SelectControl,
|
||||
ComboboxControl,
|
||||
} from "@wordpress/components";
|
||||
import "./editor.scss";
|
||||
import { Tip } from "@wordpress/components";
|
||||
import { getAdminLanguageFromCookie } from "../../utilities.js";
|
||||
import { useSelect } from "@wordpress/data";
|
||||
import { useEffect, useState } from "@wordpress/element";
|
||||
import { decodeEntities } from "@wordpress/html-entities";
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { InspectorControls } from '@wordpress/block-editor';
|
||||
import { PanelBody, SelectControl, ComboboxControl } from '@wordpress/components';
|
||||
import './editor.scss';
|
||||
import { Tip } from '@wordpress/components';
|
||||
import { getAdminLanguageFromCookie } from '../../utilities.js';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { useEffect, useState } from '@wordpress/element';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
|
||||
export default function OptionsSelectControl({ setAttributes, relatedPostId }) {
|
||||
let [postOptions, setPostOptions] = useState(null);
|
||||
|
||||
const lang = getAdminLanguageFromCookie("wp-wpml_current_language");
|
||||
const lang = getAdminLanguageFromCookie('wp-wpml_current_language');
|
||||
const optionPages = useSelect(
|
||||
(select) => {
|
||||
let query = {
|
||||
status: "publish",
|
||||
status: ['draft', 'publish'],
|
||||
per_page: -1,
|
||||
lang: lang,
|
||||
};
|
||||
return select("core").getEntityRecords("postType", "parcours", query);
|
||||
return select('core').getEntityRecords('postType', 'parcours', query);
|
||||
},
|
||||
[lang]
|
||||
);
|
||||
|
|
@ -38,7 +34,7 @@ export default function OptionsSelectControl({ setAttributes, relatedPostId }) {
|
|||
function buildSelectOptions(optionPages) {
|
||||
let options = [];
|
||||
if (optionPages && optionPages.length > 0) {
|
||||
options.push({ value: 0, label: "Selectionnez une page" });
|
||||
options.push({ value: 0, label: 'Selectionnez une page' });
|
||||
optionPages.forEach((page) => {
|
||||
options.push({
|
||||
value: page.id,
|
||||
|
|
@ -46,7 +42,7 @@ export default function OptionsSelectControl({ setAttributes, relatedPostId }) {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
options.push({ value: 0, label: "Pas encore de questions..." });
|
||||
options.push({ value: 0, label: 'Pas encore de questions...' });
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
|
@ -58,11 +54,11 @@ export default function OptionsSelectControl({ setAttributes, relatedPostId }) {
|
|||
}
|
||||
}, [optionPages]);
|
||||
|
||||
let panelTitle = "Post Parcours Reliée";
|
||||
let panelTitle = 'Post Parcours Reliée';
|
||||
|
||||
return (
|
||||
<InspectorControls>
|
||||
<PanelBody title={__("Étape parcours", "homegrade-blocks")}>
|
||||
<PanelBody title={__('Étape parcours', 'homegrade-blocks')}>
|
||||
{postOptions && (
|
||||
<ComboboxControl
|
||||
label={panelTitle}
|
||||
|
|
@ -74,8 +70,8 @@ export default function OptionsSelectControl({ setAttributes, relatedPostId }) {
|
|||
{relatedPostId && (
|
||||
<Tip>
|
||||
{__(
|
||||
"Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.",
|
||||
"homegrade-blocks"
|
||||
'Pour modifier le contenu de la question affichée ici, rendez-vous dans la fiche question correspondante.',
|
||||
'homegrade-blocks'
|
||||
)}
|
||||
</Tip>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import { useBlockProps } from "@wordpress/block-editor";
|
||||
import OptionsSelectControl from "./OptionsSelectControl";
|
||||
import { useSelect } from "@wordpress/data";
|
||||
import "./editor.scss";
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useBlockProps } from '@wordpress/block-editor';
|
||||
import OptionsSelectControl from './OptionsSelectControl';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import './editor.scss';
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { relatedPostId } = attributes;
|
||||
const post = useSelect((select) =>
|
||||
select("core").getEntityRecord("postType", "parcours", relatedPostId)
|
||||
select('core').getEntityRecord('postType', 'parcours', relatedPostId)
|
||||
);
|
||||
const stepIconUrl = useSelect(
|
||||
(select) => {
|
||||
let setpIconID = post?.acf?.step_icon;
|
||||
const media = select("core").getMedia(setpIconID);
|
||||
const media = select('core').getMedia(setpIconID);
|
||||
return media?.source_url ?? null;
|
||||
},
|
||||
[post]
|
||||
|
|
@ -20,10 +20,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<OptionsSelectControl
|
||||
relatedPostId={relatedPostId}
|
||||
setAttributes={setAttributes}
|
||||
/>
|
||||
<OptionsSelectControl relatedPostId={relatedPostId} setAttributes={setAttributes} />
|
||||
|
||||
<div
|
||||
{...useBlockProps({
|
||||
|
|
@ -32,7 +29,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
>
|
||||
{post && (
|
||||
<>
|
||||
<img class="parcours-step-card__icon" src={stepIconUrl} alt="" />
|
||||
<img className="parcours-step-card__icon" src={stepIconUrl} alt="" />
|
||||
<h3 className="parcours-step-card__title">{post.title.rendered}</h3>
|
||||
</>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
/**
|
||||
* The following styles get applied inside the editor only.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
|
||||
.wp-block-create-block-test {
|
||||
border: 1px dotted #f00;
|
||||
.homegrade-blocks-parcours-step.is-selected {
|
||||
outline: 2px solid var(--wp--preset--color--secondary, --wp-admin-theme-color, #007cba) !important;
|
||||
&:focus:after {
|
||||
position: static !important;
|
||||
outline: none !important;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user