Actions

Difference between revisions of "VueJS"

From LimeSurvey Manual

(Jest)
(Jest)
Line 68: Line 68:
 
You can type
 
You can type
  
$ yarn run test
+
<syntaxhighlight lang="bash">
 +
$ yarn run test
 +
</syntaxhighlight>
  
 
in a package folder to run all tests.
 
in a package folder to run all tests.

Revision as of 17:00, 5 May 2020

Notice.png
 Hint: This information is intended for LimeSurvey developers.

Introduction

The admin interface in LimeSurvey 4 has started a conversion to VueJS. VueJS is a reactive framework, like Angular and ReactJS. Some of the components in LimeSurvey 4 has been back-ported to LimeSurvey 3.

A reactive JavaScript framework has the potential to create a more fluid user experience by avoiding page reloads.

Documentation

VueJS has extensive documentation online: https://vuejs.org/v2/guide/

Compilation

Vue is compiled to JavaScript. To compile it, you have to install the compile tools.

Install dependencies of a package by running yarn:

$ yarn

Then build both development and production by running

$ yarn build

TODO: Some components use another build system.

Events

Vue can use events to communicate between components, for example to react when a button is clicked.

Usage

To emit an event, use

LS.EventBus.$emit("saveButtonCalled", this.button);

To subscribe:

LS.EventBus.$on("saveButtonCalled", (button) => { <do things...> });

And to unsubscribe:

LS.EventBus.$off("saveButtonCalled");

Event list

Event name Argument Description
saveButtonCalled button Fired when save button is clicked in admin top-bar
componentFormSubmit button Fired from SaveController in adminbasics when saveButtonCalled is fired
reloadTopBar data (?) Reload the admin top panel

Jest

Unit-test system for JavaScript.

You can type

$ yarn run test

in a package folder to run all tests.

Refactoring

Some refactoring tasks that are scheduled for 2020:

  • Single-root instead of multiple
  • Remove duplicated Ajax calls
  • Remove code duplication
  • Remove pjax
  • Random warnings and errors during compilation
  • Remove compiled code from Github repository

More discussion can be viewed here.