Skip to content

Commit

Permalink
Implement EZP-23263: Allow setting section & state during creation of…
Browse files Browse the repository at this point in the history
… new object
  • Loading branch information
andrerom committed Aug 15, 2014
1 parent c99d47a commit ef7ebdb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
11 changes: 11 additions & 0 deletions design/admin/templates/content/edit_menu.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@
</div>

<!-- Translation box end-->

{* Edit section *}
<div class="sections">
{include uri='design:content/parts/edit_sections.tpl'}
</div>


{* Edit states *}
<div class="states">
{include uri='design:content/parts/edit_states.tpl'}
</div>
10 changes: 6 additions & 4 deletions design/admin/templates/content/parts/edit_sections.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{* DO NOT EDIT THIS FILE! Use an override template instead. *}

{* This file is normally not required anymore but is kept for backward compatibility reason! *}

{* DESIGN: Header START *}<div class="box-header"><div class="box-ml">

{* get the sections list which consist of: sections allowed to assign to the object by the
Expand All @@ -27,7 +25,7 @@
{* show the section selector *}
<div class="block">
<label for="SelectedSectionId">{'Choose section'|i18n( 'design/admin/node/view/full' )}:</label>
<select id="SelectedSectionId" name="SelectedSectionId">
<select id="SelectedSectionId" name="SelectedSectionId"{if $object_is_draft|not()} disabled="disabled"{/if}>
{foreach $sections as $section}
{if eq( $section.id, $object.section_id )}
<option value="{$section.id}" selected="selected">{$section.name|wash}</option>
Expand All @@ -39,7 +37,11 @@
</div>

<div class="block">
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="SectionEditButton" class="button" />
{if $object_is_draft}
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="SectionEditButton" class="button" />
{else}
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="SectionEditButton" class="button-disabled" disabled="disabled" />
{/if}
</div>
{* DESIGN: Content END *}</div></div></div>

Expand Down
8 changes: 3 additions & 5 deletions design/admin/templates/content/parts/edit_states.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{* DO NOT EDIT THIS FILE! Use an override template instead. *}

{* This file is normally not required anymore but is kept for backward compatibility reason! *}

{def $enable_StateEditButton = false()}

{* DESIGN: Header START *}<div class="box-header"><div class="box-ml">
Expand All @@ -16,7 +14,7 @@
{foreach $object.allowed_assign_state_list as $allowed_assign_state_info}
<div class="block">
<label for="SelectedStateIDList">{$allowed_assign_state_info.group.current_translation.name|wash}</label>
<select id="SelectedStateIDList" name="SelectedStateIDList[]" {if $allowed_assign_state_info.states|count|eq(1)}disabled="disabled"{/if}>
<select id="SelectedStateIDList" name="SelectedStateIDList[]"{if or( $allowed_assign_state_info.states|count|eq(1), $object_is_draft|not() )} disabled="disabled"{/if}>
{if $allowed_assign_state_info.states}
{set $enable_StateEditButton = true()}
{/if}
Expand All @@ -29,10 +27,10 @@


<div class="block">
{if $enable_StateEditButton}
{if and( $enable_StateEditButton, $object_is_draft )}
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="StateEditButton" class="button" />
{else}
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="StateEditButton" class="button-disabled" />
<input type="submit" value="{'Set'|i18n( 'design/admin/node/view/full' )}" name="StateEditButton" class="button-disabled" disabled="disabled" />
{/if}
</div>
</div></div></div></div></div></div>
Expand Down
12 changes: 6 additions & 6 deletions kernel/content/attribute_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,13 @@
$tpl->setVariable( 'object', $object );
$tpl->setVariable( 'attribute_base', $attributeDataBaseName );

$locationUIEnabled = true;
$objectIsDraft = $object->attribute( 'status' ) == eZContentObject::STATUS_DRAFT;

// If the object has been published we disable the location UI
if ( $object->attribute( 'status' ) != eZContentObject::STATUS_DRAFT )
{
$locationUIEnabled = false;
}
$tpl->setVariable( "location_ui_enabled", $locationUIEnabled );
$tpl->setVariable( "location_ui_enabled", $objectIsDraft );

// Give templates easy access to check if object is draft
$tpl->setVariable( "object_is_draft", $objectIsDraft );


if ( $Module->runHooks( 'pre_template', array( $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage, $tpl, $FromLanguage ) ) )
Expand Down

0 comments on commit ef7ebdb

Please sign in to comment.