Rewrite project creation component in vanilla js
This commit is contained in:
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
<?php if (count($projects_list) > 1): ?>
|
<?php if (count($projects_list) > 1): ?>
|
||||||
<?= $this->form->label(t('Create from another project'), 'src_project_id') ?>
|
<?= $this->form->label(t('Create from another project'), 'src_project_id') ?>
|
||||||
<?= $this->form->select('src_project_id', $projects_list, $values) ?>
|
<?= $this->form->select('src_project_id', $projects_list, $values, array(), array(), 'js-project-creation-select-options') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<div class="project-creation-options" <?= isset($values['src_project_id']) && $values['src_project_id'] > 0 ? '' : 'style="display: none"' ?>>
|
<div class="js-project-creation-options" <?= isset($values['src_project_id']) && $values['src_project_id'] > 0 ? '' : 'style="display: none"' ?>>
|
||||||
<p class="alert"><?= t('Which parts of the project do you want to duplicate?') ?></p>
|
<p class="alert"><?= t('Which parts of the project do you want to duplicate?') ?></p>
|
||||||
|
|
||||||
<?php if (! $is_private): ?>
|
<?php if (! $is_private): ?>
|
||||||
|
|||||||
2
assets/css/app.min.css
vendored
2
assets/css/app.min.css
vendored
File diff suppressed because one or more lines are too long
4
assets/js/app.min.js
vendored
4
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
9
assets/js/components/project-creation-select-options.js
Normal file
9
assets/js/components/project-creation-select-options.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
KB.onChange('.js-project-creation-select-options', function (element) {
|
||||||
|
var projectId = element.value;
|
||||||
|
|
||||||
|
if (projectId === '0') {
|
||||||
|
KB.find('.js-project-creation-options').hide();
|
||||||
|
} else {
|
||||||
|
KB.find('.js-project-creation-options').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -5,6 +5,7 @@ var KB = {
|
|||||||
http: {},
|
http: {},
|
||||||
listeners: {
|
listeners: {
|
||||||
clicks: {},
|
clicks: {},
|
||||||
|
changes: {},
|
||||||
internals: {}
|
internals: {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -31,6 +32,10 @@ KB.onClick = function (selector, callback) {
|
|||||||
this.listeners.clicks[selector] = callback;
|
this.listeners.clicks[selector] = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
KB.onChange = function (selector, callback) {
|
||||||
|
this.listeners.changes[selector] = callback;
|
||||||
|
};
|
||||||
|
|
||||||
KB.listen = function () {
|
KB.listen = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@@ -43,7 +48,16 @@ KB.listen = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onChange(e) {
|
||||||
|
for (var selector in self.listeners.changes) {
|
||||||
|
if (self.listeners.changes.hasOwnProperty(selector) && e.target.matches(selector)) {
|
||||||
|
self.listeners.changes[selector](e.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('click', onClick, false);
|
document.addEventListener('click', onClick, false);
|
||||||
|
document.addEventListener('change', onChange, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
KB.component = function (name, object) {
|
KB.component = function (name, object) {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
Kanboard.ProjectCreation = function(app) {
|
|
||||||
this.app = app;
|
|
||||||
};
|
|
||||||
|
|
||||||
Kanboard.ProjectCreation.prototype.onPopoverOpened = function() {
|
|
||||||
$('#project-creation-form #form-src_project_id').on('change', function() {
|
|
||||||
var srcProjectId = $(this).val();
|
|
||||||
|
|
||||||
if (srcProjectId == 0) {
|
|
||||||
$(".project-creation-options").hide();
|
|
||||||
} else {
|
|
||||||
$(".project-creation-options").show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
&:hover, &:focus
|
&:hover, &:focus
|
||||||
text-decoration: underline
|
text-decoration: underline
|
||||||
|
|
||||||
.project-creation-options
|
.js-project-creation-options
|
||||||
max-width: 500px
|
max-width: 500px
|
||||||
border-left: 3px dotted #efefef
|
border-left: 3px dotted #efefef
|
||||||
margin-top: 20px
|
margin-top: 20px
|
||||||
|
|||||||
Reference in New Issue
Block a user