cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Modify Attributes dialog child new window from acl?

largyres
Newbie

How to make Modify Attributes dialog child new window from acl?

Adepters

Epic 5.1b Win 2K
When a user chooses File, New [doctype] an instance.acl file calls a
function that prompts to set an attribute on the root tag. If opening
existing file with the attr already set function doesn't prompt. Looks
something like:

if (no_tag) { oid_modify_attr(oid_first_tag(current_doc()),'practiceArea');
}

Works fine except that when an existing file is already open the Modify
Attributes dialog becomes a child of the existing doc window and is hidden
from the user who's left looking at the template file. (Switching windows to
the first file and setting the attribute *does* modify the new file
attribute.)
I'm not conversant with dialog or window functions but I've tried using:

current_window([my_new_win],[my_new_doc])
and
modfy_tag 'my_doctype' -attr 'practiceArea'

...to no avail. How do I make the Modify Attributes dialog a child of the
new window so the user can find it?

Thanks.

- Lou

Lou Argyres
Continuing Education of the Bar - California
300 Frank Ogawa Plaza, Suite 410
Oakland, CA 94612
Lou.Argyres@ceb.ucop.edu
510-302-2097


Tags (2)
4 REPLIES 4

Re: How to make Modify Attributes dialog child new window from acl?

Maybe it's the point at which your code executes (template not yet loaded?).

How about the document 'create' callback? This could be defined in an ACL file read once / session.

Untested example:

package promptRootAttr;

global registeredDoctypes[];

# If doc's doctype is registered, prompt for its configured root attr if not set.
function createCallback( doc )
{
# Consider adding more error checking; i.e., valid doc, valid shelf value, etc.

local doctype = doc_type( doc );
if ( defined( registeredDoctypes[ doctype ] ) )
{
local o = oid_first( doc );
if ( oid_valid( o ) && ( oid_attr( o, registeredDoctypes[ doctype ] ) == '' ) )
{
# Optionally retain caret location here and restore after mt command.
goto_oid( o );
modify_tag;
}
}
}

function initPackage()
{
# Associative array where doctype name is index; shelf value is root attr name.
# Alternatively, you can have each [doctype].acl register themselves.
registeredDoctypes[ "doctype1" ] = "practiceArea";
registeredDoctypes[ "doctype2" ] = "differentAttrName1";
registeredDoctypes[ "doctype3" ] = "differentAttrName2";
doc_add_callback( 0, 'create', 'promptRootAttr::createCallback' );
}

initPackage();

Re: How to make Modify Attributes dialog child new window from acl?

Thanks for the code Brent. Worked perfectly out of the box except that the
Modify Attributes dialog for a new doc is still a child of the first
document when one is already open. Again it modifies the attribute of the
new doc.

It does indeed look like the template file has not loaded. I tested using
tag_attr_choices(oid_first_tag(), 'practiceArea', arr)
to load a list_response() function by hand with attr choices and that
generates an error saying that the array is empty.

Back to the drawing board.

- Lou

Lou Argyres
Continuing Education of the Bar - California
300 Frank Ogawa Plaza, Suite 410
Oakland, CA 94612
Lou.Argyres@ceb.ucop.edu
510-302-2097


Re: How to make Modify Attributes dialog child new window from acl?

Hi, Lou,

It's too early to go back to the drawing board! I reproduced the issue in 5.1B. Turns out the new doc's window is valid but not yet displayed. Here's a version I think you'll like.

package promptRootAttr;

global registeredDoctypes[];

# If doc's doctype is registered, prompt for its configured root attr if not set.
function createCallback( doc )
{
local doctype = doc_type( doc );
local win = current_window();
local wState = window_state( win );
if ( (wState >= 0) && defined( registeredDoctypes[ doctype ] ) )
{
local o = oid_first( doc );
if ( oid_valid( o ) && ( oid_attr( o, registeredDoctypes[ doctype ] ) == '' ) )
{
# Optionally retain caret location here and restore after mt command.
window_show( win, 1 );
goto_oid( o );
modify_tag;
}
}
}

function initPackage()
{
# Associative array where doctype name is index; shelf value is root attr name.
# Alternatively, you can have each [doctype].acl register themselves.
registeredDoctypes[ "axdocbook" ] = "id";
registeredDoctypes[ "doctype2" ] = "differentAttrName1";
registeredDoctypes[ "doctype3" ] = "differentAttrName2";
doc_add_callback( 0, 'create', 'promptRootAttr::createCallback' );
}

initPackage();

Re: How to make Modify Attributes dialog child new window from acl?

Thanks so much Brent. window_show() did the trick!

- Lou
Announcements