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

SiteTree labels don't correct indicate modified status #434

Open
robbieaverill opened this issue Jul 6, 2018 · 1 comment
Open

SiteTree labels don't correct indicate modified status #434

robbieaverill opened this issue Jul 6, 2018 · 1 comment

Comments

@robbieaverill
Copy link
Contributor

robbieaverill commented Jul 6, 2018

CWP 2.1.x-dev, SilverStripe 4.2.x-dev, Fluent 4.1.x-dev

Background:

  • Create an English and a German locale
  • Create a page in the German locale
  • Publish the page in both locales
  • Modify the page and save it in the English locale
  • Switch to the German locale

Expected: the German version of the page is published and does not contain any unpublished changes

Actual: the German version of the page is published but indicates in the page tree that there are unpublished changes on it (from the English locale)


The fix for this may also involve needing to add another method isDraftInStage to FluentVersionedExtension to identify when a page is in its initial draft stage in a given locale (but has never been published in that locale).

Noticed while testing how Fluent behaves when looking at silverstripe/silverstripe-lumberjack#75, which isn't correctly indicating any versioned state in a lumberjack GridField "state" column.

@cwchong
Copy link

cwchong commented Apr 10, 2019

I am encountering something similar but am not very sure whether they are the same issue. I fixed this by creating an extension to FluentSiteTreeExtension:

namespace FC\Extensions;

use TractorCow\Fluent\Extension\FluentSiteTreeExtension;

class FixFluentSiteTreeExtension extends FluentSiteTreeExtension {
    
    public function updateStatusFlags(&$flags) {
        parent::updateStatusFlags($flags);

        if($this->isPublishedInLocale()) {
            unset($flags['modified']);
            unset($flags['addedtodraft']);
        } elseif($this->isDraftedInLocale()) {
            unset($flags['modified']);
            $flags['addedtodraft'] = array(
                'text' => _t(FluentSiteTreeExtension::class.'.ADDEDTODRAFTSHORT', 'Draft'),
                'title' => _t(FluentSiteTreeExtension::class.'.ADDEDTODRAFTHELP', "Page has not been published yet")
            );
            // this simplistically assumes no unsaved modifications as long as draft exist in the locale
        }
        
    }
}

and then applying this extension:

SilverStripe\Core\Injector\Injector:
  TractorCow\Fluent\Extension\FluentSiteTreeExtension:
    class: FC\Extensions\FixFluentSiteTreeExtension

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

2 participants