[Rt-commit] rt branch, 4.6/lifecycle-ui-dev, updated. rt-4.4.4-625-g0d92d4fbb3
Craig Kaiser
craig at bestpractical.com
Tue Jan 7 17:27:17 EST 2020
The branch, 4.6/lifecycle-ui-dev has been updated
via 0d92d4fbb320a8b3743b1eda2639e89a40211168 (commit)
from 9703d800400240a5dd0f4372ca04a227dc32e2d7 (commit)
Summary of changes:
lib/RT/Lifecycle.pm | 29 +++++++++++++----------------
share/html/Admin/Lifecycles/Modify.html | 18 +++++++++---------
share/html/Elements/Lifecycle/Graph | 16 ++++++++--------
share/static/js/lifecycleui-editor.js | 16 ++++++++--------
share/static/js/lifecycleui-model.js | 6 +++---
5 files changed, 41 insertions(+), 44 deletions(-)
- Log -----------------------------------------------------------------
commit 0d92d4fbb320a8b3743b1eda2639e89a40211168
Author: Craig Kaiser <craig at bestpractical.com>
Date: Tue Jan 7 17:24:28 2020 -0500
Use RT::Configuration to store lifecycle config instead of RT::Attribute
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 6cf6649c6a..0cefacbbf1 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -922,36 +922,33 @@ sub UpdateLifecycle {
CurrentUser => undef,
LifecycleObj => undef,
NewConfig => undef,
- Attribute => undef,
+ Configuration => undef,
@_,
);
- if ( $args{'Attribute'} ) {
- my $attribute = RT::Attribute->new( RT->SystemUser );
+ if ( $args{'Configuration'} ) {
+ my $config = RT::Configuration->new( RT->SystemUser );
- if ( $attribute->LoadByNameAndObject( Object => RT::System, Name => 'LifecycleAttribute-'.$args{'LifecycleObj'}->Name ) ) {
- my ($ret, $msg) = $attribute->SetContent( $args{'Attribute'} );
+ if ( $config->Load( 'LifecycleConfiguration-'.$args{'LifecycleObj'}->Name ) ) {
+ my ($ret, $msg) = $config->SetContent( $args{'Configuration'} );
if ( $ret ) {
- RT::Logger->debug("Updating existing lifeycle attribute for " . $args{'LifecycleObj'}->Name);
+ RT::Logger->debug("Updating existing lifeycle configuration for " . $args{'LifecycleObj'}->Name);
}
else {
- RT::Logger->debug("Could not update attribute for lifecycle ".$args{'LifecycleObj'}->Name.": $msg");
+ RT::Logger->debug("Could not update configuration for lifecycle ".$args{'LifecycleObj'}->Name.": $msg");
}
}
else {
- my ($ret, $msg) = $attribute->Create(
- Name => 'LifecycleAttribute-'.$args{'LifecycleObj'}->Name,
- Description => 'LifecycleAttribute-'.$args{'LifecycleObj'}->Name,
- Content => $args{'Attribute'},
- Object => RT::System,
- ContentType => 'storable',
- ObjectType => 'RT::System'
+ my ($ret, $msg) = $config->Create(
+ Name => 'LifecycleConfiguration-'.$args{'LifecycleObj'}->Name,
+ Content => $args{'Configuration'},
+ ContentType => 'perl',
);
if ( $ret ) {
- RT::Logger->debug("Creating lifecycle attribute for: ".$args{'LifecycleObj'}->Name);
+ RT::Logger->debug("Creating lifecycle configuration for: ".$args{'LifecycleObj'}->Name);
}
else {
- RT::Logger->debug("Could not create lifecycle attribute for ".$args{'LifecycleObj'}->Name.": $msg");
+ RT::Logger->debug("Could not create lifecycle configuration for ".$args{'LifecycleObj'}->Name.": $msg");
}
}
}
diff --git a/share/html/Admin/Lifecycles/Modify.html b/share/html/Admin/Lifecycles/Modify.html
index 8dc762b6a5..5483bcc511 100644
--- a/share/html/Admin/Lifecycles/Modify.html
+++ b/share/html/Admin/Lifecycles/Modify.html
@@ -70,12 +70,12 @@ Abort("Invalid lifecycle") unless $LifecycleObj->Name
$title = loc("Modify lifecycle [_1]", $LifecycleObj->Name);
if ($Config) {
- my $LifecycleAttribute = JSON::from_json($LifecycleAttribute);
+ my $LifecycleConfiguration = JSON::from_json($LifecycleConfiguration);
my ($ok, $msg) = RT::Lifecycle->UpdateLifecycle(
- CurrentUser => $session{CurrentUser},
- LifecycleObj => $LifecycleObj,
- NewConfig => JSON::from_json($Config),
- Attribute => $LifecycleAttribute,
+ CurrentUser => $session{CurrentUser},
+ LifecycleObj => $LifecycleObj,
+ NewConfig => JSON::from_json($Config),
+ Configuration => $LifecycleConfiguration,
);
if ( $ok ) {
push @results, "Lifecycle updated";
@@ -92,8 +92,8 @@ MaybeRedirectForResults(
);
</%INIT>
<%ARGS>
-$Name => undef
-$Type => undef
-$Config => undef
-$LifecycleAttribute => undef
+$Name => undef
+$Type => undef
+$Config => undef
+$LifecycleConfiguration => undef
</%ARGS>
diff --git a/share/html/Elements/Lifecycle/Graph b/share/html/Elements/Lifecycle/Graph
index 045d8a3888..99e01f78e9 100644
--- a/share/html/Elements/Lifecycle/Graph
+++ b/share/html/Elements/Lifecycle/Graph
@@ -83,11 +83,11 @@
<script type="text/javascript">
jQuery(function () {
var container = document.getElementById('lifecycle-<% $id %>'),
- config = <% JSON($config) |n %>,
- name = <% $Lifecycle | j%>,
- attribute = <% $attribute |n %>;
+ config = <% JSON($config) |n %>,
+ name = <% $Lifecycle | j%>,
+ configuration = <% $configuration |n %>;
- var editor = new RT.NewEditor( container, config, attribute );
+ var editor = new RT.NewEditor( container, config, configuration );
});
</script>
<div>
@@ -119,10 +119,10 @@ $Lifecycle ||= $Ticket->Lifecycle
my $config = RT->Config->Get('Lifecycles')->{$Lifecycle};
Abort("Invalid Lifecycle") if !$Lifecycle || !$config;
-my $attributes = RT::Attributes->new( RT->SystemUser );
-$attributes->Limit( FIELD => 'Description', VALUE => "LifecycleAttribute-$Lifecycle" );
-my $attribute = $attributes->First;
-$attribute = $attribute ? JSON($attribute->Content) : "{}";
+my $configurations = RT::Configurations->new( RT->SystemUser );
+$configurations->Limit( FIELD => 'Name', VALUE => "LifecycleConfiguration-$Lifecycle" );
+my $configuration = $configurations->First;
+$configuration = $configuration ? JSON($configuration->_DeserializeContent($configuration->Content)) : "{}";
my $id = $Lifecycle . '-' . int(rand(2**31));
</%INIT>
diff --git a/share/static/js/lifecycleui-editor.js b/share/static/js/lifecycleui-editor.js
index 9ec0be44a4..7504cb1964 100644
--- a/share/static/js/lifecycleui-editor.js
+++ b/share/static/js/lifecycleui-editor.js
@@ -1,17 +1,17 @@
jQuery( document ).ready(function () {
RT.NewEditor = class LifecycleEditorNew extends LifecycleModel {
- constructor(container, config, attribute) {
+ constructor(container, config, configuration) {
super("LifecycleModel");
var self = this;
self.width = 900;
self.height = 350;
self.node_radius = 35;
- self.attribute = attribute;
+ self.configuration = configuration;
self.initial = 1;
self.enableSimulation = 1;
- if ( Object.keys(self.attribute).indexOf('checked') == -1 || self.attribute && self.attribute['checked'] ) {
+ if ( Object.keys(self.configuration).indexOf('checked') == -1 || self.configuration && self.configuration['checked'] ) {
jQuery('#enableSimulation').prop( "checked", true );
}
else {
@@ -67,8 +67,8 @@ jQuery( document ).ready(function () {
else self.links.push({id: ++self.links_seq, source: source, target: target, start: false, end: true});
});
if ( !self.enableSimulation ) {
- if (self.attribute[source.name][0]) source.x = parseFloat(self.attribute[source.name][0]);
- if (self.attribute[source.name][1]) source.y = parseFloat(self.attribute[source.name][1]);
+ if (self.configuration[source.name][0]) source.x = parseFloat(self.configuration[source.name][0]);
+ if (self.configuration[source.name][1]) source.y = parseFloat(self.configuration[source.name][1]);
}
});
@@ -160,9 +160,9 @@ jQuery( document ).ready(function () {
pos[d.name] = [d.x, d.y];
});
- var attribute = jQuery('<input name="LifecycleAttribute" type="hidden">');
- attribute.val(JSON.stringify(pos));
- form.append(attribute);
+ var configuration = jQuery('<input name="LifecycleConfiguration" type="hidden">');
+ configuration.val(JSON.stringify(pos));
+ form.append(configuration);
self.initial = 0;
self.ExportAsConfiguration();
diff --git a/share/static/js/lifecycleui-model.js b/share/static/js/lifecycleui-model.js
index d2617bd7ba..a824909f4b 100644
--- a/share/static/js/lifecycleui-model.js
+++ b/share/static/js/lifecycleui-model.js
@@ -266,7 +266,7 @@ class LifecycleModel {
var pos = {};
if ( jQuery('#enableSimulation').is(":checked") ) {
- pos = JSON.parse(jQuery('input[name="LifecycleAttribute"]').val())
+ pos = JSON.parse(jQuery('input[name="LifecycleConfiguration"]').val())
pos["checked"] = 1;
}
else {
@@ -276,7 +276,7 @@ class LifecycleModel {
pos["checked"] = 0;
}
- var attribute = jQuery('input[name="LifecycleAttribute"]');
- attribute.val(JSON.stringify(pos));
+ var configuration = jQuery('input[name="LifecycleConfiguration"]');
+ configuration.val(JSON.stringify(pos));
};
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list