How to use the strapi-helper-plugin.templateObject function in strapi-helper-plugin

To help you get started, we’ve selected a few strapi-helper-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / components / SelectOne / index.js View on Github external
.then(response => {
        const options = isArray(response)
          ? map(response, item => ({
            value: item,
            label: templateObject(
              { mainField: this.props.relation.displayedAttribute },
              item,
            ).mainField,
          }))
          : [
            {
              value: response,
              label: templateObject(
                { mainField: this.props.relation.displayedAttribute },
                response,
              ).mainField,
            },
          ];

        const newOptions = cloneDeep(this.state.options);
        options.map(option => {
          // Don't add the values when searching
          if (
            findIndex(newOptions, o => o.value.id === option.value.id) === -1
          ) {
            return newOptions.push(option);
          }
        });
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditView / index.js View on Github external
strapi.notification.success(`${pluginId}.success.record.delete`);
      redirectToPreviousPage();
    } catch (err) {
      setIsSubmitting(false);
      strapi.notification.error(`${pluginId}.error.record.delete`);
    }
  };

  const displayedFieldNameInHeader = get(
    layout,
    ['settings', 'mainField'],
    'id'
  );
  const pluginHeaderTitle = isCreatingEntry
    ? { id: `${pluginId}.containers.Edit.pluginHeader.title.new` }
    : templateObject({ mainField: displayedFieldNameInHeader }, initialData)
        .mainField;
  const displayedRelations = get(layout, ['layouts', 'editRelations'], []);
  const hasRelations = displayedRelations.length > 0;
  const fields = get(layout, ['layouts', 'edit'], []);

  const checkFormErrors = async () => {
    const schema = createYupSchema(layout, { groups: groupLayoutsData });
    let errors = {};

    try {
      // Validate the form using yup
      await schema.validate(modifiedData, { abortEarly: false });
    } catch (err) {
      errors = get(err, 'inner', []).reduce((acc, curr) => {
        acc[
          curr.path
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditView / index.js View on Github external
strapi.notification.success(`${pluginId}.success.record.delete`);
      redirectToPreviousPage();
    } catch (err) {
      setIsSubmitting(false);
      strapi.notification.error(`${pluginId}.error.record.delete`);
    }
  };

  const displayedFieldNameInHeader = get(
    layout,
    ['settings', 'mainField'],
    'id'
  );
  const pluginHeaderTitle = isCreatingEntry
    ? { id: `${pluginId}.containers.Edit.pluginHeader.title.new` }
    : templateObject({ mainField: displayedFieldNameInHeader }, initialData)
        .mainField;
  const displayedRelations = get(layout, ['layouts', 'editRelations'], []);
  const hasRelations = displayedRelations.length > 0;
  const fields = get(layout, ['layouts', 'edit'], []);

  const checkFormErrors = async () => {
    const schema = createYupSchema(layout, { groups: groupLayoutsData });
    let errors = {};

    try {
      // Validate the form using yup
      await schema.validate(modifiedData, { abortEarly: false });
    } catch (err) {
      errors = getYupInnerErrors(err);
    }
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / EditView / Header.js View on Github external
setIsSubmitting,
    slug,
  } = useDataManager();

  const currentContentTypeMainField = get(
    layout,
    ['settings', 'mainField'],
    'id'
  );
  const isCreatingEntry = id === 'create';

  const headerTitle = isCreatingEntry
    ? formatMessage({
        id: `${pluginId}.containers.Edit.pluginHeader.title.new`,
      })
    : templateObject({ mainField: currentContentTypeMainField }, initialData)
        .mainField;

  const getHeaderActions = () => {
    const headerActions = [
      {
        onClick: () => {
          toggleWarningCancel();
        },
        color: 'cancel',
        title: formatMessage({
          id: `${pluginId}.containers.Edit.reset`,
        }),
        type: 'button',
        style: {
          paddingLeft: 15,
          paddingRight: 15,
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / components / SelectOne / index.js View on Github external
? map(response, item => ({
            value: item,
            label: templateObject(
              { mainField: this.props.relation.displayedAttribute },
              item,
            ).mainField,
          }))
          : [