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

[4.1] Allow save as copy article in the frontend #32520

Closed
wants to merge 1,488 commits into from

Conversation

joomdonation
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

This PR adds support for Save As Copy article from frontend of your site

Testing Instructions

  1. Apply Patch.
  2. Login to frontend of your site using an account which has permission to edit an existing article
  3. Edit the an existing article. Look at the Bottom of the page, if you are using an account which is having Create Article Permission, you will see a new button Save As Copy to allows you to create new article base on that existing article
  4. Press Save As Copy button, confirm that the article is successfully created.

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.0-dev labels Feb 26, 2021
@ghost
Copy link

ghost commented Feb 26, 2021

Is it possible to turn off this feature?

Testing Instructions
can you provide data for article base on that existing article?

@richard67
Copy link
Member

@chnnst The testing instructions are complete and clear enough for everybody who is familiar with Joomla.

@toivo
Copy link
Contributor

toivo commented Feb 26, 2021

I have tested this item 🔴 unsuccessfully on 3615d42

Received an error when accessing an unpublished article and then pressing either Save as Copy or Save: 0 Invalid field: Start Featured. The test was done in Beta8-dev updated to 26 February in Wampserver using PHP 8.0.2. However, the same error occurred after the patch was reverted.

The same Author user was able to save a new article without problems and the Publishing tab did not include any Featured option. When teh Author user edited this last article, the Featured option in Publishing showed 'No' and then pushing Save resulted the same error, 0 Invalid field: Start Featured

Will now install the lastest Beta8-dev from scratch for further testing.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@himanshu007-creator
Copy link
Contributor

I have tested this item ✅ successfully on debf2f2

before applying the patch, there was no option named "SAVE AS COPY". After applying the patch , the option showed up and worked as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@ghost
Copy link

ghost commented Feb 26, 2021

@richard67 joomdonation Is it possible to turn off this feature?

@joomdonation
Copy link
Contributor Author

@chnnst Don't worry about it. This feature is not accepted yet. If it is accepted and you don't like this feature, you can easy turn it off by implementing a template override.

@ghost
Copy link

ghost commented Feb 26, 2021

We don't want a template override, we want an option button to turn this feature off.
this feature should be postponed to 4.1 we need j.4 release now.

@joomdonation
Copy link
Contributor Author

@chnnst You do not need it does not mean other users do not need it. This is up to maintainers to decide. You or me do not have the right to make decision.

@richard67
Copy link
Member

The easiest way to switch it off is to use an account for frontend editing who has the permission to edit existing articles but not to create new ones.

@ghost
Copy link

ghost commented Feb 26, 2021

@richard67 that's awkward way to switch it off, better way is an option button to turn this feature off.

can you provide real life data for article base on that existing article? To understand why you need this feature to be implemented?

@joomdonation
Copy link
Contributor Author

@chnnst Joomla! has Save As Copy option for long time from administrator area. This PR just makes that option available for frontend.

If it is not needed, then people would not open this discussion #28092 . If it is not needed, then Joomla won't need Save As Copy feature in administrator area

You want Joomla 4 to release NOW, so please stop wasting time of other people to answer your questions for nothing.

@toivo
Copy link
Contributor

toivo commented Feb 26, 2021

Not even the Save button is working from the front end for an Author user in an unpatched out-of-the-box full version of Beta8-dev just installed today. The error message is always "0 Invalid field: Start Featured", independent of the state of Featured, whether the Start Featured date was selected from the Calendar icon or not.

I will raise a new item about this error.

Test environment:
Windows 10, Wampserver 3.2.4
Apache 2.4.46c, MySQL 8.0.23, PHP 8.0.2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@joomdonation
Copy link
Contributor Author

Thanks @toivo . Please open a new issue for that. I will try to look at it later today (please give me a clear instructions to see the error)

@ghost
Copy link

ghost commented Feb 26, 2021

@joomdonation your new feature which are not needed create new issues, please stop proposing them to j4 but better propose them to 4.1 or later .

We want Joomla 4 to release NOW, so please stop wasting time of other people, and better test release blockers.

@toivo
Copy link
Contributor

toivo commented Feb 26, 2021

@chnnst @joomdonation - The error "0 Invalid field: Start Featured" occurs in an out-of-the-box Beta8-dev in my Windows test environment with PHP 8.0.2, independent of any patches.

Here are the steps I followed:

Beta8-dev full version installed on Wampserver, PHP 8.0.2

Create an Author user.

Content - Categories and create a new category, 'My Category'.

Add a menu item to Main Menu, Create Article and select 'My Category' as the category.
Add a menu item to Main Menu, Category List, and select 'My Category' as the category.
Add a menu item to Main Menu, Category Blog, and select 'My Category' as the category.

Login as the Author user. Create an article from the front end.
The article shows as unpublished and assigned to My Category from the back end.
Publish the article.

Edit the article from the front end as the Author user.
The Featured field has the value No and Start Featured is blank.
Save the article.

Expected result: The article is saved

Result: 0 Invalid field: Start Featured

Go to the Category Blog and edit the article.
Change the option Feature to Yes and leave Start Featured blank.
Save - 0 Invalid field: Start Featured

Go to the Category Blog and edit the article.
Change the option Feature to Yes and select Today from the calendar link in the field Start Featured.
Clickin Save ends with "0 Invalid field: Start Featured"


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@joomdonation
Copy link
Contributor Author

Thanks @toivo. I will try to re-procedure the issue myself and get it sorted.

@toivo
Copy link
Contributor

toivo commented Feb 26, 2021

The front end Author user already had the permissions 'Edit' and 'Edit State' to that particle article from Author to Publisher but was unable to save the article without the error. After the user group of this front end user was changed from Author to Publisher, this user was able to save the article without issues.

I will raise this as a new issue now.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@toivo
Copy link
Contributor

toivo commented Feb 26, 2021

It turns out that giving to the user group Author the permission to Edit State in an article or the category causes the error.

Changed the 'Edit State' permission to Inherited and therefore by calculation 'Not Allowed (Inherited)' in the article and granted the Edit State permission to Author in the category. When the Author tries to save the article from the front end, we get "0 Invalid field: Start Featured."

When the 'Edit State' permission is changed back to 'Inherited' and therefore by calculation 'Not Allowed (Inherited)', the Author user can save the article without any issues.

Perhaps this is not an issue. Should we say that an Author with the permission 'Edit State' should be a Publisher instead? Otherwise we will have an endless number of permutations of items, categories, user groups and permissions that some of our users think should work.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@joomdonation
Copy link
Contributor Author

@toivo It is actually an issue with permission checking. I will find a way to solve it.

@ceford
Copy link
Contributor

ceford commented Feb 26, 2021

I have tested this item 🔴 unsuccessfully on debf2f2

I followed the instructions: logged in as Super User, edited Article in Front End and clicked Save as Copy - the new article was not created, any changes were saved in the existing article. I tried again, changed the Title and clicked Save as Copy - the existing article was saved with the new title. I tried in the back-end - the new article was created there. This was using a new clone created a couple of days ago.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@joomdonation
Copy link
Contributor Author

@ceford You at least need to change Title of the article before press Save As Copy button to have article created, otherwise, you will see an error message

That same behavior is applied for Save As Copy button in the backend.

So in short, you need to change Title of the article (so that a unique Alias will be generated for the new article) to have the article created

@ceford
Copy link
Contributor

ceford commented Feb 26, 2021

@ceford You at least need to change Title of the article before press Save As Copy button to have article created, otherwise, you will see an error message

That same behavior is applied for Save As Copy button in the backend.

So in short, you need to change Title of the article (so that a unique Alias will be generated for the new article) to have the article created

In the backend test I did not change the Title - the system appended (2) to the existing title and created a new alias.

@joomdonation
Copy link
Contributor Author

@ceford OK. I will check that backend behavior to see how it is handled and make adjustment here. Could you confirm that if you change Title of article before pressing Save As Copy, the new article is being created properly?

@ceford
Copy link
Contributor

ceford commented Feb 26, 2021

I am using Multi-lingual Test Data. I tried changing the article title with Save as Copy and it just save the existing article with the new title.

@joomdonation
Copy link
Contributor Author

@toivo Could you please check to see if PR #32524 solves the issue you are having?

@ChristineWk
Copy link

ChristineWk commented Feb 26, 2021

@joomdonation steps 1 - 3 = OK, but Step 4: "0 Invalid field: Start Featured."
Tested before: PR #32524 x was successful. Above PR I can't test, because I hv to revert previous PR :-)
What I'm doing wrong?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32520.

@joomdonation
Copy link
Contributor Author

@ChristineWk Thanks for testing. We have a bug need to be fixed first before we can continue with this PR. So please wait until the PR #32524 is merged before testing it again

Many thanks !

@simbus82
Copy link
Contributor

simbus82 commented Feb 26, 2021

@richard67 that's awkward way to switch it off, better way is an option button to turn this feature off.

can you provide real life data for article base on that existing article? To understand why you need this feature to be implemented?

In my case around 200 websites where authors everytime have to redo the same article structure in frontend, because save&copy doesn't exist. Only solution is let they can access to the admin, and this is wrong, really wrong.

Phil E. Taylor and others added 13 commits August 24, 2021 09:51
When updating a component the success message should be green not blue
The description for the group of this module has not been updated since the module was enhanced and changed in J4. As a result the information about the core icons is not correct any more and this PR resolves that.
* btn sizes

* Subform styling for non table layout

* scss cs

* scss cs

* scss cs

* Highlight draggable section

* Highlight same color as other site
Shorten the user list headlines to improve the width of the user list table
* [4.0] download key tip

* change to a link

* remove debug

* style

* fix styles and link

* route

* updated tooltip

* id
Comment on lines +184 to +196
// If the article is being edited and the current user has permission to create article
if ($this->item->id
&& ($user->authorise('core.create', 'com_content') || \count($user->getAuthorisedCategories('com_content', 'core.create'))))
{
$showSaveAsCopy = true;
}
else
{
$showSaveAsCopy = false;
}

$this->showSaveAsCopy = $showSaveAsCopy;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things here:

  1. $this->showSaveAsCopy should be defined as (protected?) class variable
  2. why this extra variable $showSaveAsCopy either assign it direct to $this->showSaveAsCopy or do something like:
    $this->showSaveAsCopy = $this->item->id && ....;

@@ -161,6 +161,12 @@
<span class="icon-check" aria-hidden="true"></span>
<?php echo Text::_('JSAVE'); ?>
</button>
<?php if ($this->showSaveAsCopy) : ?>
<button type="button" class="btn btn-primary" data-submit-task="article.save2copy">
<span class="icon-check" aria-hidden="true"></span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a copy icon?

@bembelimen bembelimen added this to the Joomla 4.1 milestone Aug 26, 2021
This reverts commit 55faa61, reversing
changes made to 07454ef.
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators and removed Unit/System Tests labels Aug 26, 2021
@joomdonation
Copy link
Contributor Author

Sorry. I merged 4.0-dev into this branch and messed up the PR. Will close this one for now and redo it later.

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 26, 2021
@joomdonation joomdonation deleted the frontend_save_as_copy branch November 26, 2021 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet