Skip to content

Commit

Permalink
move related js: according to change request
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Nov 7, 2023
1 parent 3de7def commit 0919944
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage;
use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroup;
use srag\Plugins\Opencast\DI\OpencastDIC;

/**
* Class xoctPublicationSubUsageFormGUI
Expand Down Expand Up @@ -38,6 +39,14 @@ class xoctPublicationSubUsageFormGUI extends ilPropertyFormGUI
* @var bool $is_new
*/
protected $is_new = true;
/**
* @var ilOpenCastPlugin
*/
protected $plugin;
/**
* @var OpencastDIC
*/
protected $container;


/**
Expand All @@ -47,9 +56,12 @@ class xoctPublicationSubUsageFormGUI extends ilPropertyFormGUI
public function __construct($parent_gui, $xoctPublicationSubUsage, $is_new = true)
{
global $DIC;
$this->container = OpencastDIC::getInstance();
$this->plugin = $this->container->plugin();
$DIC->ui()->mainTemplate()->addJavaScript(
ilOpenCastPlugin::getInstance()->getDirectory() . '/templates/default/publication_usage_form.min.js'
$this->plugin->getDirectory().'/js/opencast/dist/index.js'
);
$DIC->ui()->mainTemplate()->addOnLoadCode('il.Opencast.Form.publicationUsage.init()');
parent::__construct();
$this->object = $xoctPublicationSubUsage;
$this->parent_gui = $parent_gui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage;
use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroup;
use srag\Plugins\Opencast\DI\OpencastDIC;

/**
* Class xoctPublicationUsageFormGUI
Expand Down Expand Up @@ -38,6 +39,14 @@ class xoctPublicationUsageFormGUI extends ilPropertyFormGUI
* @var xoctPublicationUsageGUI
*/
protected $parent_gui;
/**
* @var ilOpenCastPlugin
*/
protected $plugin;
/**
* @var OpencastDIC
*/
protected $container;

/**
* @param xoctPublicationUsageGUI $parent_gui
Expand All @@ -47,9 +56,12 @@ public function __construct($parent_gui, $xoctPublicationUsage)
{
global $DIC;
$ctrl = $DIC->ctrl();
$this->container = OpencastDIC::getInstance();
$this->plugin = $this->container->plugin();
$DIC->ui()->mainTemplate()->addJavaScript(
ilOpenCastPlugin::getInstance()->getDirectory() . '/templates/default/publication_usage_form.min.js'
$this->plugin->getDirectory().'/js/opencast/dist/index.js'
);
$DIC->ui()->mainTemplate()->addOnLoadCode('il.Opencast.Form.publicationUsage.init()');
parent::__construct();
$this->object = $xoctPublicationUsage;
$this->parent_gui = $parent_gui;
Expand Down
2 changes: 1 addition & 1 deletion js/opencast/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions js/opencast/src/Form/PublicationUsage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
*
* PublicationUsage class
*
* @author Farbod Zamani Boroujeni <zamani@elan-ev.de>
*/
export default class PublicationUsage {
/**
* @type {jQuery}
*/
jquery;

constructor(
jquery,
){
this.jquery = jquery;
}

init() {
$(function() {
$('select#md_type').on('change', function() {
if (this.value === "0") {
$('#il_prop_cont_search_key').hide();
$('#il_prop_cont_allow_multiple').hide();
$('#il_prop_cont_mediatype').hide();
} else {
$('#il_prop_cont_search_key').show();
$('#il_prop_cont_allow_multiple').show();
$('#il_prop_cont_mediatype').show();
}
});

$('select#md_type').trigger('change');
})
}
}
3 changes: 3 additions & 0 deletions js/opencast/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import il from 'ilias';
import $ from 'jquery';
import PasswordToggle from './Form/PasswordToggle';
import PublicationUsage from './Form/PublicationUsage';

il.Opencast = il.Opencast || {};
il.Opencast.Form = il.Opencast.Form || {};
il.Opencast.Form.passwordToggle = new PasswordToggle($);

il.Opencast.Form.publicationUsage = new PublicationUsage($);
15 changes: 0 additions & 15 deletions templates/default/publication_usage_form.js

This file was deleted.

1 change: 0 additions & 1 deletion templates/default/publication_usage_form.min.js

This file was deleted.

0 comments on commit 0919944

Please sign in to comment.