Skip to content

Add usage of Shopware.Snippet.tc() to admin js #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2024
Merged

Add usage of Shopware.Snippet.tc() to admin js #1422

merged 3 commits into from
Jun 28, 2024

Conversation

despokd
Copy link
Contributor

@despokd despokd commented Jun 26, 2024

Real live example:

import CMS from '../../constant/custom.constant'
import template from './custom-anchor.html.twig';

export default {
    template,

    inject: ['repositoryFactory'],

    props: {
        anchor: {
            type: String,
            default: {
                type: 'anchor',
                value: '#anchor',
                content: 'Lorem Ipsum',
                entityId: null
            }
        },
        hideContent: {
            type: Boolean,
            default: false
        }
    },

    emits: [
        'update:anchor',
    ],

    data: () => {
        return {
            CMS,
            types: [
                {
                    name: Shopware.Snippet.tc('custom.general.anchor'),
                    id: 'anchor'
                },
                {
                    name: Shopware.Snippet.tc('global.entities.category'),
                    id: 'category'
                },
                {
                    name: Shopware.Snippet.tc('global.entities.landing_page'),
                    id: 'landing_page'
                },
                {
                    name: Shopware.Snippet.tc('global.entities.product'),
                    id: 'product'
                },
            ]
        };
    },

    computed: {
        anchor: {
            get() {
                return this.anchor;
            },
            set(value) {
                this.$emit('update:anchor', value);
            }
        },

        onChangeType() {
            // trigger type change to change template
            this.$emit('update:anchor', this.anchor);
        }
    },
};

@Isengo1989 Isengo1989 merged commit 58699a9 into shopware:main Jun 28, 2024
5 of 6 checks passed
@Isengo1989
Copy link
Contributor

@despokd Thank you for improving the docs 🎉

@despokd despokd deleted the patch-2 branch June 28, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants