BUGFIX: changing from "magic" number labels for drop down states to word labels

This commit is contained in:
Julian Seidenberg 2012-08-14 15:05:23 +12:00
parent 8aff01a608
commit 9d0f8ade7e
2 changed files with 16 additions and 15 deletions

View File

@ -521,17 +521,17 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
'<li class="ss-ui-button" data-panel="find-usage">Find usage</li>'. '<li class="ss-ui-button" data-panel="find-usage">Find usage</li>'.
'</ul></div>')); '</ul></div>'));
$embargoValue = 0; $embargoValue = 'None';
if ($this->EmbargoedForever) $embargoValue = 2; if ($this->EmbargoedForever) $embargoValue = 'Forever';
elseif ($this->EmbargoedUntilPublished) $embargoValue = 1; elseif ($this->EmbargoedUntilPublished) $embargoValue = 'Published';
elseif (!empty($this->EmbargoedUntilDate)) $embargoValue = 3; elseif (!empty($this->EmbargoedUntilDate)) $embargoValue = 'Date';
$embargo = new OptionsetField('Embargo','Embargo',array('None','Hide document until page is published','Hide document forever','Hide until set date'),$embargoValue); $embargo = new OptionsetField('Embargo','Embargo',array('None'=>'None','Published'=>'Hide document until page is published','Forever'=>'Hide document forever','Date'=>'Hide until set date'),$embargoValue);
$embargoDatetime = DatetimeField::create('EmbargoedUntilDate',''); $embargoDatetime = DatetimeField::create('EmbargoedUntilDate','');
$embargoDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'yyyy-MM-dd')->setConfig('datavalueformat', 'yyyy-MM-dd'); $embargoDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'yyyy-MM-dd')->setConfig('datavalueformat', 'yyyy-MM-dd');
$expiryValue = 0; $expiryValue = 'None';
if (!empty($this->ExpireAtDate)) $expiryValue = 1; if (!empty($this->ExpireAtDate)) $expiryValue = 'Date';
$expiry = new OptionsetField('Expiry','Expiry',array('None','Set document to expire on'),$expiryValue); $expiry = new OptionsetField('Expiry','Expiry',array('None'=>'None','Date'=>'Set document to expire on'),$expiryValue);
$expiryDatetime = DatetimeField::create('ExpireAtDate',''); $expiryDatetime = DatetimeField::create('ExpireAtDate','');
$expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'yyyy-MM-dd')->setConfig('datavalueformat', 'yyyy-MM-dd'); $expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'yyyy-MM-dd')->setConfig('datavalueformat', 'yyyy-MM-dd');
@ -559,15 +559,16 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
if (isset($this->Embargo)) { if (isset($this->Embargo)) {
//set the embargo options from the OptionSetField created in the getCMSFields method //set the embargo options from the OptionSetField created in the getCMSFields method
//do not write after clearing the embargo (write happens automatically) //do not write after clearing the embargo (write happens automatically)
if ($this->Embargo != 3) $this->clearEmbargo(false); //clear all previous settings and re-apply them on save $savedDate = $this->EmbargoedUntilDate;
$this->clearEmbargo(false); //clear all previous settings and re-apply them on save
if ($this->Embargo == 1) $this->embargoUntilPublished(false); if ($this->Embargo == 'Published') $this->embargoUntilPublished(false);
if ($this->Embargo == 2) $this->embargoForever(false); if ($this->Embargo == 'Forever') $this->embargoForever(false);
if ($this->Embargo == 3) $this->embargoUntilDate($this->EmbargoedUntilDate, false); if ($this->Embargo == 'Date') $this->embargoUntilDate($savedDate, false);
} }
if (isset($this->Expiry)) { if (isset($this->Expiry)) {
if ($this->Expiry == 1) $this->expireAtDate($this->ExpireAtDate, false); if ($this->Expiry == 'Date') $this->expireAtDate($this->ExpireAtDate, false);
else $this->clearExpiry(false); //clear all previous settings else $this->clearExpiry(false); //clear all previous settings
} }
} }

View File

@ -46,7 +46,7 @@
$('#Form_ItemEditForm_Embargo input').entwine({ $('#Form_ItemEditForm_Embargo input').entwine({
onchange: function() { onchange: function() {
//selected the date options //selected the date options
if (this.attr('value') == 3) { if (this.attr('value') === 'Date') {
$('.embargoDatetime').show(); $('.embargoDatetime').show();
} else { } else {
$('.embargoDatetime').hide(); $('.embargoDatetime').hide();
@ -57,7 +57,7 @@
$('#Form_ItemEditForm_Expiry input').entwine({ $('#Form_ItemEditForm_Expiry input').entwine({
onchange: function() { onchange: function() {
//selected the date options //selected the date options
if (this.attr('value') == 1) { if (this.attr('value') === 'Date') {
$('.expiryDatetime').show(); $('.expiryDatetime').show();
} else { } else {
$('.expiryDatetime').hide(); $('.expiryDatetime').hide();