- Timestamp:
- 04/27/12 11:34:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm
r949 r951 249 249 sub attr_field_name { 250 250 my ($self, $attr) = @_; 251 return ($self->{object} 252 ? $self->{object}->id . '_' 253 : '' 254 ) . $attr 251 my $id = $self->{object} 252 ? $self->{object}->id . '_' 253 : ''; 254 $id =~ s/\./_/g; 255 $id . $attr; 255 256 } 256 257 … … 288 289 my $html_id = $htmlname . 289 290 (scalar(@html_fields) ? scalar(@html_fields) : ''); 291 $html_id .= 'NB' if ($attribute->multiple); 290 292 291 293 my $html_field = ''; 294 my $html_ref = ''; 292 295 for ($attribute->form_type) { 293 296 /^textarea$/i and do { … … 403 406 } 404 407 if ($attribute->uniq) { 405 $html_ field.= qq|<span class="inputvalidate" id="${html_id}_observer_uniq"></span>|;406 $html_ field.= "\n";407 $html_ field.= $self->{c}->prototype->observe_field(408 $html_ref .= qq|<span class="inputvalidate" id="${html_id}_observer_uniq"></span>|; 409 $html_ref .= "\n"; 410 $html_ref .= $self->{c}->prototype->observe_field( 408 411 $html_id, 409 412 { … … 418 421 } 419 422 ); 420 $html_ field.= qq|<span style="display:none" id="${html_id}_stat">Searching...</span>|;423 $html_ref .= qq|<span style="display:none" id="${html_id}_stat">Searching...</span>|; 421 424 } 422 425 last; … … 439 442 } 440 443 441 $html_ field.= $self->{c}->prototype->observe_field( $html_id, {444 $html_ref .= $self->{c}->prototype->observe_field( $html_id, { 442 445 update => "${html_id}_span", 443 446 url => $self->{c}->uri_for('/ajax', 'rawattr', $ref), … … 453 456 ) 454 457 } 455 $html_ field.= sprintf(qq{<span id="%s" style="margin-left: 1em">},458 $html_ref .= sprintf(qq{<span id="%s" style="margin-left: 1em">}, 456 459 "${html_id}_span"); 457 460 458 461 if (defined($text)) { 459 $html_ field.= $uri_part462 $html_ref .= $uri_part 460 463 ? sprintf('<a href="%s">%s</a>', 461 464 $self->{c}->uri_for("/$uri_part", $attribute->display($attr_raw_value)), … … 464 467 } 465 468 466 $html_ field.= "</span>\n";469 $html_ref .= "</span>\n"; 467 470 } 468 push(@html_fields, $html_field); 471 push(@html_fields, $html_field . $html_ref); 472 if ($attribute->{multiple} && (!$attr_raw_value)) { 473 my $esc_html_field = $html_field; 474 my $esc_html_ref = $html_ref; 475 $esc_html_ref =~ s/'/\\'/g; 476 #$esc_html_field =~ s/"/\\"/g; 477 my $addempty = sprintf( 478 '<div id="%s"></div>', 479 "${html_id}_mul_emp0", 480 ); 481 $addempty .= sprintf(qq# 482 <script type="text/javascript"> 483 var cn_${html_id} = 0; 484 function add_${html_id} () { 485 cn_${html_id}++; 486 var cn = cn_${html_id}; 487 var htmlid = '${html_id}'.replace(/NB/g, cn); 488 document.getElementById('${html_id}_mul_emp' + (cn - 1)).innerHTML += 489 '%s<span class="inputvalidate" id="${html_id}_observer_uniq"></span><br>'.replace(/NB/g, cn); 490 document.getElementById('${html_id}_mul_emp' + (cn - 1)).innerHTML += 491 '<div id="${html_id}_mul_emp' + cn + '"></div>'; 492 493 new Form.Element.Observer( '${html_id}'.replace('NB', cn), 494 2, 495 function( element, value ) { 496 new Ajax.Updater( '${html_id}_observer_uniq'.replace(/NB/g, cn), 497 'http://localhost:8080/ajax/objattrexist/nethost/cname', 498 { parameters: 'val='+document.getElementById(htmlid).value+'&exclude=$attr_raw_value',asynchronous: 1 } ) 499 } ); 500 } 501 </script> 502 <button type="button" onclick="add_${html_id}()">+</button> 503 #, 504 $esc_html_field 505 ); 506 push(@html_fields, $addempty); 507 } 469 508 } 470 509 return join("<br>\n", @html_fields); … … 495 534 my ($self, $attrs) = @_; 496 535 $self->{c}->req->param($self->label) || $attrs or return; 497 my $prefix = $self-> {object}->id . '_';536 my $prefix = $self->attr_field_name(''); 498 537 my %fields; 499 538 foreach ($attrs ? @{ $attrs } : $self->write_attributes) {
Note: See TracChangeset
for help on using the changeset viewer.