Development

#1753 (Use input_in_place_editor_tag as Ajax.InPlaceCollectionEditor)

You must first sign up to be able to contribute.

Ticket #1753 (closed enhancement: fixed)

Opened 1 year ago

Last modified 7 months ago

Use input_in_place_editor_tag as Ajax.InPlaceCollectionEditor

Reported by: Serg.Kalachev Assigned to: FabianLange
Priority: major Milestone: 1.1.0
Component: helpers Version: 1.0.2
Keywords: javascript Cc:
Qualification: Design decision

Description

Intro

Ajax.InPlaceCollectionEditor allow user dynamicaly (in-place) choose options from select DOM element instead of input or textarea using input_in_place_editor_tag helper.

How to use

There are several new options for input_in_place_editor_tag.

collection   array   List of options to display (key => value)
value        int     Initially selected value

If option collection is set, collection mode is activated.

Also, developer can redefine some strings via options in both modes:

click_to_edit_text
loading_text
saving_text

Modification

1) Change line 817

<?php
...
      $javascript = "new Ajax.InPlaceEditor(";
...

to

<?php
...
      $javascript = sprintf( "new Ajax.InPlace%sEditor(", 
         (isset($options['collection'])) ? 'Collection' : '' );
...

2) Add new lines after line 865(871)

<?php
...
  if (isset($options['click_to_edit_text']))
  {
    $js_options['clickToEditText'] = "'".$options['click_to_edit_text']."'";
  }
  if (isset($options['loading_text']))
  {
    $js_options['loadingText'] = "'".$options['loading_text']."'";
  }
  if (isset($options['saving_text']))
  {
    $js_options['savingText'] = "'".$options['saving_text']."'";
  }
  if (isset($options['empty_text']))
  {
    $js_options['emptyText'] = "'".$options['empty_text']."'";
  }
  if (isset($options['collection']))
  {
    $str = '';
    foreach( $options['collection'] as $key => $value )
    {
      if(!empty($str)) $str .= ',';
      $str .= sprintf("[%d, '%s']", $key, $value );
    }
    $js_options['collection'] =  "[$str]";
  }
  if (isset($options['value']))
  {
    $js_options['value'] =  sprintf( '%d', $options['value']);
  }
...

Change History

06/09/07 10:11:46 changed by fabien

  • milestone deleted.

03/11/08 17:36:47 changed by FabianLange

  • owner changed from fabien to FabianLange.
  • status changed from new to assigned.
  • qualification set to Design decision.
  • milestone set to 1.1.0.

03/13/08 10:19:34 changed by FabianLange

  • status changed from assigned to closed.
  • resolution set to fixed.

as with r7855 the in place editor will now pass through options as you pass them into. only some special cases have been preserved for backwards compatibility.