Skip to content

Commit bddbe16

Browse files
Merge branch '4.2' into 4
2 parents c1978d3 + 9f19bae commit bddbe16

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

client/dist/js/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/entwine/LinkField.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ jQuery.entwine('ss', ($) => {
2828

2929
refresh() {
3030
const props = this.getProps();
31-
this.getInputField().val(props.value);
31+
// Set the value attribute specifically with a "string array" when using a MultiLinkField
32+
// This is done to ensure the change-tracker works as expected otherwise the intial form state
33+
// will not match the component after it's refreshed, which happens when it's mounted
34+
let value = props.value;
35+
if (value && value.constructor === Array) {
36+
value = '[' + value.join(',') + ']';
37+
}
38+
this.getInputField().val(value);
3239
const ReactField = this.getComponent();
3340
const Root = this.getRoot();
3441
Root.render(<ReactField {...props} noHolder/>);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
@retry @job2
2+
Feature: Create Links in LinkField and MultiLinkField
3+
As a content editor
4+
I want to add links to pages, files, external URLs, email addresses and phone numbers
5+
6+
Background:
7+
Given I add an extension "SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension" to the "Page" class
8+
And I go to "/dev/build?flush"
9+
And a "page" "Link Page"
10+
And a "image" "folder1/file1.jpg"
11+
And the "group" "EDITOR" has permissions "Access to 'Pages' section"
12+
And I am logged in as a member of "EDITOR" group
13+
And I go to "/admin/pages"
14+
And I should see "Link Page"
15+
And I click on "Link Page" in the tree
16+
# Publish the page straight away
17+
And I click on the "#Form_EditForm_action_publish" element
18+
And I wait for 3 seconds
19+
20+
Scenario: Change tracker single link
21+
# save/publish buttons will get .btn.primary class when clicking them will make a change to the database
22+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
23+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
24+
# Create email link in single LinkField
25+
When I click on the "[data-field-id='Form_EditForm_HasOneLink'] button" element
26+
Then I should see "Link to email address" in the "[data-field-id='Form_EditForm_HasOneLink'] .dropdown-item:nth-of-type(2)" element
27+
When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .dropdown-item:nth-of-type(2)" element
28+
And I wait for 3 seconds
29+
Then I should see "Link to email address" in the ".modal-header" element
30+
Then I fill in "LinkText" with "Email link"
31+
And I fill in "Email" with "email@example.com"
32+
And I press the "Create link" button
33+
And I wait for 2 seconds
34+
# Because of the use of AJAX, the save button should not be highlighted, though the publish button should
35+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
36+
And I should see a "#Form_EditForm_action_publish.btn-primary" element
37+
# Publish the page
38+
When I click on the "#Form_EditForm_action_publish" element
39+
And I wait for 3 seconds
40+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
41+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
42+
# Check that clicking on an unrelated input field doesn't activate the change tracker
43+
When I click on the "#Form_EditForm_Title" element
44+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
45+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
46+
47+
Scenario: Change tracker multi link
48+
# save/publish buttons will get .btn.primary class when clicking them will make a change to the database
49+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
50+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
51+
# Create PhoneLink in MultiLinkField
52+
When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] button" element
53+
Then I should see "Phone number" in the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element
54+
When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element
55+
And I wait for 3 seconds
56+
Then I should see "Phone number" in the ".modal-header" element
57+
Then I fill in "LinkText" with "Phone"
58+
Then I fill in "Phone" with "12345678"
59+
And I should not see "Open in new window" in the ".modal-content" element
60+
And I press the "Create link" button
61+
And I wait for 2 seconds
62+
# Because of the use of AJAX, the save button should not be highlighted, though the publish button should
63+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
64+
And I should see a "#Form_EditForm_action_publish.btn-primary" element
65+
# Publish the page
66+
When I click on the "#Form_EditForm_action_publish" element
67+
And I wait for 3 seconds
68+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
69+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
70+
# Check that clicking on an unrelated input field doesn't activate the change tracker
71+
When I click on the "#Form_EditForm_Title" element
72+
Then I should not see a "#Form_EditForm_action_save.btn-primary" element
73+
And I should not see a "#Form_EditForm_action_publish.btn-primary" element
74+

0 commit comments

Comments
 (0)