1. Erik Segerdell
  2. Valentina Studio
  3. 木, 7月 18 2024, 09:16 PM
  4.  メールで購読
Hello,
I have designed a form that uses the import mechanism to import other forms for various uses. For example, clicking a button should run the JS code:


import '/For Admins/Experiment/add-experiment' as dlg
dlg.exec()


This would normally open a new form window to "add experiment".This functionality appears to be broken in the newest version of Valentina Studio, 14.1.2. Nothing happens when the buttons are clicked. This was worked normally up to and including version 13.
コメント
There are no comments made yet.
Vladimir Esipov 承諾済みの回答
Valentina Studio 14 introduces important changes to scripting, including the ability to use JavaScript and Python modules.
Try it

dlg =project.loadForm( '/For Admins/Experiment/add-experiment' )
dlg.exec()
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Hello Erik,

Yes, there are a few things that were changed - importing forms and scripts, and Qt classes usage.

From the release notes:
Valentina Studio 14 has important changes in scripting due to the addition of the ability to utilize JavaScript and Python modules, so the following adjustments need to be made to existing scripts:

import '/forms/form_1' as
dlg
is replaced by


dlg = project.loadForm( '/forms/form_1' )




import '/scripts/script_1'
function1();

is replaced by


m = project.loadModule( '/scripts/script_1' );
m.function1();


Access to Qt classes is done via the “qt” object, e.g.:

s = qt.QSettings( 'Car Catalogs', 'Car Catalog' );
コメント
There are no comments made yet.
Erik Segerdell 承諾済みの回答
Thanks. It helps fix a few things. We’ve developed a pretty complex application that is used by a scientific research group to enter data, and unfortunately many parts of it are affected by the update.

The most critical part of our application is that users will enter data about an "experiment", which has a unique experiment ID in the database, and then they will click a button to open a new form that shows one or more "plates", which have unique plate IDs. The plates are normally filtered so that users only see the ones which are related to the specific experiment. Currently, the following script is executed when the users click the button to open the plates:


records = this.table.getTableCursor( this.uuid )
field = records.getField( 'experiment_id' )
experiment_id = field.value

// an SQL query returns the min and max plate_id values which are related to the current experiment_id
qres = this.dataSource.sqlSelect( 'SELECT ...' )
min = qres.getField( 'min' ).value
max = qres.getField( 'max' ).value

// use the new way to import the plates form
dlg = project.loadForm( '/For Admins/Plates/plate-observation' )

// in the imported form, show only the range of plates associated with the experiment
dlg.records.addFilter( 'plate_id BETWEEN ' + min + ' AND ' + max )
dlg.records.applyFilters()
dlg.ExpSubForm.records.reloadRecords()
dlg.ObservationsTableView.reload()
dlg.exec()


The new form does not open with this code. If I move the dlg.exec() line so it is right after the addFilter line, the new window opens but the records are not filtered.

Another more minor issue: we use the following script in the QObject needUpdate signal in order to grey out navigation buttons when the user is on the first record in a form. However, the presence of that code now results in a lot of errors when the form is first opened (see attached screenshot).


records = this.table.getTableCursor( this.uuid )
sender.enabled = records.position > 0
添付ファイル
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Hello Eric,
Thank you.
We'll create a new build (or beta build) soon with fixes for these issues.
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
A test build is available for download:
参照
  1. http://valentina-db.com/download/prev_releases/14.1.5/
コメント
There are no comments made yet.
  • ページ :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories