
     +h                         d Z  G d de          Z G d de          Z G d de          Z G d de          Z G d	 d
e          ZdS )z,Classes for class-based forward declaration.c                   .    e Zd ZdZed             Zd ZdS )Forwardz0Base class for autocomplete forward declaration.c                      t          d          )z2Forward type. Should be implemented in subclasses.zPlease use one of my subclasses)NotImplementedErrorselfs    O/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/dal/forward.pytypezForward.type   s     ""CDDD    c                     d| j         iS )5Convert to dictionary which will be rendered as JSON.r	   )r	   r   s    r   to_dictzForward.to_dict   s     DI
 	
r
   N)__name__
__module____qualname____doc__propertyr	   r    r
   r   r   r      sE        ::E E XE
 
 
 
 
r
   r   c                   .     e Zd ZdZdZddZ fdZ xZS )Fielda  Forward field value.

    The type of the forwarded value from the field is either string, list of
    strings or boolean.

    The following rules are used to deduce the forwarded type.

     - If there is only one field in the form or subform with name ``src``
    and this field is a checkbox without ``value`` HTML-attribute,
    then boolean value indicating if this checkbox is checked is forwarded.

     - If there is only one field in the form or subform with name ``src``
    and it has ``multiple`` HTML-attribute, then this field is forwarded as a
    list of strings, containing values from this field.

    - If there are one or more fields in the form with name ``src`` and all of
    them are checkboxes with HTML-attribute ``value`` set the list of strings
    containing checked checkboxes is forwarded.

    - Otherwise ``src`` field value forwarded as a string.

    .. py:attribute:: src

        The name of the form field whose value will be forwarded to a view.

    .. py:attribute:: dst

        The name of the key of the forwarded value from the src field in the
        forwarded dictionary. If this value is ``None``, then the key is
        ``src``.
    fieldNc                 "    || _         || _        dS z$Instantiate a forwarded field value.N)srcdst)r   r   r   s      r   __init__zField.__init__6       r
   c                     t          t          |                                           }|                    | j                   | j        |                    | j                   |S )r   )r   Nr   )superr   r   updater   r   r   d	__class__s     r   r   zField.to_dict;   sW    %&&((	TX8HHH"""r
   Nr   r   r   r   r	   r   r   __classcell__r#   s   @r   r   r      s^         @ D   
        r
   r   c                   ,     e Zd ZdZdZd Z fdZ xZS )ConstzForward arbitrary constant value.

    .. py:attribute:: val

        The value to forward. Must be JSON-serializable.

    .. py:attribute:: dst

        The name of the key of the forwarded value.
    constc                 "    || _         || _        dS )z'Instantiate a forwarded constant value.N)valr   )r   r,   r   s      r   r   zConst.__init__T   r   r
   c                     t          t          |                                           }|                    | j                   |                    | j                   |S )r   )r,   r   )r   r)   r   r    r,   r   r!   s     r   r   zConst.to_dictY   sO    %&&((	TX	TXr
   r%   r'   s   @r   r)   r)   F   sX        	 	 D  
        r
   r)   c                   .     e Zd ZdZdZddZ fdZ xZS )
JavaScriptaH  Run registered javascript handler and forward its returned value.

    You can register custom forward handler in your JS code as follows:

    .. code-block:: javascript

    yl.registerForwardHandler("your_handler", function (autocompleteElement) {
        // your code here
    });

    Then if your add ``JavaScript("your_handler", "some_value")`` to your
    forwards declaration, your function will be called, autocomplete field
    HTML element will be passed as ``autocompleteElement`` and returned value
    will be added to forward dictionary with ``some_value`` key.

    .. py:attribute:: handler

    The name of the registered handler.

    .. py:attribute:: dst

    The name of the key of the forwarded value from the src field in the
    forwarded dictionary. If this value is ``None``, then the key is
    ``handler``
    
javascriptNc                 "    || _         || _        dS )zInitialize Javascript class.N)handlerr   )r   r2   r   s      r   r   zJavaScript.__init__   s    r
   c                     t          t          |                                           }|                    | j                   |                    | j                   |S )r   )r2   r   )r   r/   r   r    r2   r   r!   s     r   r   zJavaScript.to_dict   sO    *d##++--	&&&	TXr
   r$   r%   r'   s   @r   r/   r/   c   s]         4 D   
        r
   r/   c                   .     e Zd ZdZdZddZ fdZ xZS )Selfa#  Forward own value.

    The same as :class:`Field`, except that `src` is always this field
    itself.

    .. py:attribute:: dst

    The name of the key of the forwarded value from the src field in the
    forwarded dictionary. If this value is ``None``, then the key is
    ``self``.
    r   Nc                     || _         dS r   r   )r   r   s     r   r   zSelf.__init__   s    r
   c                     t          t          |                                           }| j        |                    | j                   |S )r   Nr   )r   r5   r   r   r    r!   s     r   r   zSelf.to_dict   sA    $%%''8HHH"""r
   r$   r%   r'   s   @r   r5   r5      s]        
 
 D           r
   r5   N)r   objectr   r   r)   r/   r5   r   r
   r   <module>r9      s    2 2
 
 
 
 
f 
 
 
0 0 0 0 0G 0 0 0f    G   :) ) ) ) ) ) ) )X    7     r
   