Skip to content
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

Beim kopieren werden Einträge nicht umbenannt #109

Closed
HellPat opened this issue Apr 10, 2015 · 14 comments
Closed

Beim kopieren werden Einträge nicht umbenannt #109

HellPat opened this issue Apr 10, 2015 · 14 comments
Assignees
Milestone

Comments

@HellPat
Copy link

HellPat commented Apr 10, 2015

In meinem Fall bei Metamodels.

Ich dupliziere ein Rendersetting.
Danach sieht das so aus:

bildschirmfoto 2015-04-10 um 12 18 11

ich weiß nun nicht welches das schon verwendete ist, und welches das neue.
(Außer ich schaue mir die ID an)

Mein Vorschlag ist, wie bei Contao den Namen auf _1 _2 etc. zu setzen.

@discordier
Copy link
Member

Besser waere es beim duplicate in die edit maske zu wechseln, denn wie will man definieren welche properties nun suffixed werden sollen. Zumal das bei selects usw. nicht einmal moeglich ist.

@zonky2
Copy link
Contributor

zonky2 commented Jan 14, 2016

könnte man nicht wie bei Contao-Core ein "(Kopie)" hinten ansetzen - wer das nicht möchte, könnte das "DCA-Konform" auch abschalten

@zonky2
Copy link
Contributor

zonky2 commented Mar 25, 2016

aktuell (DCG-b34) gibt eine Fehlermeldung beim Duplizieren von Render-Einstellungen oder Eingabemasken

Fatal error: Uncaught exception ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException with message Unparsable encoded id value: '' thrown in C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Data\ModelId.php on line 118

#0 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\BaseConfigRegistry.php(163): ContaoCommunityAlliance\DcGeneral\Data\ModelId::fromSerialized(NULL)
#1 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\BaseConfigRegistry.php(185): ContaoCommunityAlliance\DcGeneral\BaseConfigRegistry->buildBaseConfig(NULL)
#2 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Contao\Event\Subscriber.php(338): ContaoCommunityAlliance\DcGeneral\BaseConfigRegistry->getBaseConfig()
#3 [internal function]: ContaoCommunityAlliance\DcGeneral\Contao\Event\Subscriber->initializePanels(Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent), 'dc-general.acti...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#4 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\symfony\event-dispatcher\EventDispatcher.php(181): call_user_func(Array, Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent), 'dc-general.acti...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#5 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\symfony\event-dispatcher\EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'dc-general.acti...', Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent))
#6 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Controller\DefaultController.php(131): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('dc-general.acti...', Object(ContaoCommunityAlliance\DcGeneral\Event\ActionEvent))
#7 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\composer\vendor\metamodels\core\src\MetaModels\BackendIntegration\Module.php(74): ContaoCommunityAlliance\DcGeneral\Controller\DefaultController->handle(Object(ContaoCommunityAlliance\DcGeneral\Action))
#8 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\system\modules\core\classes\Backend.php(423): MetaModels\BackendIntegration\Module->generate()
#9 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\system\modules\core\controllers\BackendMain.php(131): Contao\Backend->getBackendModule('metamodels')
#10 C:\Contao2Go\htdocs\vhosts\contao-3.5.x\contao\main.php(20): Contao\BackendMain->run()
#11 {main}

ein Ansatzpunkt für das Hinzufügen des "(Kopie)" wäre z.B. in https://github.com/contao-community-alliance/dc-general/blob/master/src/ContaoCommunityAlliance/DcGeneral/Controller/DefaultController.php#L462-L489
mit

    private function handleClonedModelProperty(
        ModelInterface $model,
        PropertyInterface $property,
        DataProviderInterface $dataProvider
    ) {
        $extra    = $property->getExtra();
        $propName = $property->getName();

        // Check doNotCopy.
        if (isset($extra['doNotCopy']) && $extra['doNotCopy'] === true) {
            $model->setProperty($propName, null);
            return;
        }

        // Check fallback.
        if (isset($extra['fallback']) && $extra['fallback'] === true) {
            $dataProvider->resetFallback($propName);
        }

        // Check uniqueness.
        if (isset($extra['unique'])
            && $extra['unique'] === true
            && !$dataProvider->isUniqueValue($propName, $model->getProperty($propName))
        ) {
            // Implicit "do not copy" unique values, they cannot be unique anymore.
            $model->setProperty($propName, null);
        }

+        // Add '(Copy)' to property 'name'.
+        if ($propName == 'name') {
+          $model->setProperty($propName, sprintf($GLOBALS['TL_LANG']['MSC']['copyOf'], $model->getProperty($propName)));
+        }
    }

Test:

shot174

wobei hier eine "feste Verdrahtung" zu 'name' wäre - lt. @baumannsven hat @discordier eine flexiblere Lösung im Blick...

@asaage
Copy link

asaage commented Mar 25, 2016

Das selbe Problem besteht auch bei ModelItems (In deinem Fall wären das dann wohl "Mitarbeiter").
Vielleicht kann man sich generell auf eine "feste Verdrahtung" zu 'name' festlegen!?

@baumannsven
Copy link
Member

Dieser hotfix müsste das Problem lösen.
#213

stefanheimes added a commit that referenced this issue Apr 28, 2016
This should fix the problem with the "Unparsable encoded ...".
@baumannsven
Copy link
Member

Hier würde ich vorschlagen das property dem der Kopierhinweis angehängt werden soll im config zu konfigurieren.

$GLOBALS['TL_DCA']['thisTable']['config']['copyProperty'] = 'title';

@discordier , @stefanheimes Was meint ihr dazu?

@discordier
Copy link
Member

Kein Fan davon...

  1. Damit haben wir wieder Zeugs im DCA, welches in den Container an die property config gehoert.
  2. Es ist nicht klar WAS an der Property modifiziert werden soll (suffix, prefix, infix, whatever).

Das sollte man nochmal genauer yberdenken.

@baumannsven
Copy link
Member

Wenn ich dich richtig verstanden, meinst du im Field config.
Dort könnte man das mit sprintf wie z.b. beim Label Formatter lösen.

@discordier
Copy link
Member

Ja, theoretisch ist das moeglich, aber dann nicht aus dem Code heraus auf das DCA zugreifen sondern einen neuen Getter an die PropertyDefinition anbauen.

@baumannsven
Copy link
Member

@discordier

Diesen Gedanken hatte ich auch. Dann werde ich mich darum kümmern, wenn ich mit dem finalen Deep Copy fertig bin.

@zonky2 zonky2 added this to the 2.0.0 milestone Aug 30, 2016
@zonky2
Copy link
Contributor

zonky2 commented Mar 15, 2017

@baumannsven kommt das nach dem edit/overrideAll "auf den Tisch" ;-)

@baumannsven
Copy link
Member

@zonky2 Ja das kommt dann mit dem final deep copy

@zonky2
Copy link
Contributor

zonky2 commented Mar 16, 2017

o.k. - dann verbinde ich das mal mit #191

@baumannsven baumannsven modified the milestones: 2.0.0, 2.2.0 Jun 5, 2018
@baumannsven baumannsven added this to Todo in Release 2.2.0 via automation Mar 21, 2020
@zonky2 zonky2 removed this from Todo in Release 2.2.0 May 11, 2022
@zonky2 zonky2 modified the milestones: 2.2.0, 2.3.0 May 11, 2022
@zonky2
Copy link
Contributor

zonky2 commented Jul 8, 2023

Besser waere es beim duplicate in die edit maske zu wechseln, denn wie will man definieren welche properties nun suffixed werden sollen.

DCG 2.3: das ist der Fall auch bei MM-Items wie Mitarbeiter

@zonky2 zonky2 closed this as completed Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants