Commit 6727941e authored by Arnold Hendriks's avatar Arnold Hendriks

Merge branch 'feature/fix-duplicate-cloneoncopy' into 'master'

Fix duplicate copying uncloned contenttypes

Closes #10

See merge request webhare/platform!228
parents 4c49c604 d78fd6a5
......@@ -1373,7 +1373,9 @@ PUBLIC STATIC OBJECTTYPE ObjectProps EXTEND TolliumScreenBase
STRING compname := "contentdata";
TRY
{
IF (ObjectExists(extendprop.instance))
// Read current contenttype from (source)file or use default (in case of a new file)
// If this is a duplication action we must only read data if cloneoncopy hasn't been set to FALSE
IF (ObjectExists(extendprop.instance) AND (NOT this->isduplicate OR extendprop.instance->type->cloneoncopy))
extendprop.instance->ReadInstanceFromFSObject();
FOREVERY(OBJECT comp FROM extendprop.compositions)
......@@ -1400,8 +1402,10 @@ PUBLIC STATIC OBJECTTYPE ObjectProps EXTEND TolliumScreenBase
olddata := DEFAULT RECORD;
}
// Read defaults for this type
comp->ReadInstanceFromFSObject();
// Read current contenttype from (source)file or use default (in case of a new file)
// If this is a duplication action we must only read data if cloneoncopy hasn't been set to FALSE
IF (NOT this->isduplicate OR comp->type->cloneoncopy)
comp->ReadInstanceFromFSObject();
IF (RecordExists(olddata))
{
......
......@@ -77,6 +77,7 @@ ASYNC MACRO CreateUsingTemplates()
created := GetTestsuiteTempFolder()->OpenByName("index.rtd");
testfw->BeginWork();
created->SetInstanceData("http://www.webhare.net/xmlns/webhare_testsuite/basetestprops", [ anyfield := "TestDuplication" ]);
created->SetInstanceData("http://www.webhare.net/xmlns/webhare_testsuite/nocopyprops", [ idfield := "Unique identifier" ]);
testfw->CommitWork();
TestEq(TRUE, ObjectExists(created));
TestEq(TRUE, created->publish); //marked as 'publish'
......@@ -102,6 +103,8 @@ ASYNC MACRO CreateUsingTemplates()
AWAIT ExpectScreenChange(+1, PTR TTClick("duplicate"));
TestEq("index-1.rtd", TT("name")->value);
TestEq("TestDuplication", topscreen->GetExtendedComponent("http://www.webhare.net/xmlns/webhare_testsuite/basetestprops", "anyfield")->value);
// The 'nocopyprops' properties (having cloneoncopy set to false) should not have been copied
TestEq("", topscreen->GetExtendedComponent("http://www.webhare.net/xmlns/webhare_testsuite/nocopyprops", "idfield")->value);
AWAIT ExpectScreenChange(-1, PTR TTClick(":OK"));
created := GetTestsuiteTempFolder()->OpenByName("index-1.rtd");
......
......@@ -200,6 +200,23 @@
<extendproperties contenttype="http://www.webhare.net/xmlns/webhare_testsuite/basetestprops" extension="#basetestprops" />
</apply>
<!-- Content type that isn't copied -->
<contenttype namespace="http://www.webhare.net/xmlns/webhare_testsuite/nocopyprops" cloneoncopy="false">
<member name="idfield" type="string" />
</contenttype>
<tabsextension xmlns="http://www.webhare.net/xmlns/tollium/screens"
name="nocopyprops"
implementation="none">
<newtab title="BaseTestProps">
<textedit composition="contentdata" cellname="idfield" title="idfield" />
</newtab>
</tabsextension>
<apply>
<to type="all" />
<extendproperties contenttype="http://www.webhare.net/xmlns/webhare_testsuite/nocopyprops" extension="#nocopyprops" />
</apply>
<!-- Capture subpath tests -->
<contenttype namespace="http://www.webhare.net/xmlns/webhare_testsuite/capturesubpath/staticcontent" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment