mirror of
https://github.com/moodle/moodle.git
synced 2025-04-07 09:23:31 +02:00
MDL-61899 tool_dataprivacy: Separate the retention period in 2 css selectors
This commit is contained in:
parent
837b937511
commit
8b451d25f2
@ -1 +1 @@
|
||||
define(["jquery"],function(a){var b={PURPOSE_SELECT:"#id_purposeid",RETENTION_FIELD:".form-control-static"},c=function(a){this.purposeRetentionPeriods=a,this.registerEventListeners()},d=function(){a(b.PURPOSE_SELECT).off("change")};return c.prototype.purposeRetentionPeriods=[],c.prototype.registerEventListeners=function(){a(b.PURPOSE_SELECT).on("change",function(c){var d=a(c.currentTarget).val(),e=this.purposeRetentionPeriods[d];a(b.RETENTION_FIELD).each(function(){var b=a(this),c=b.siblings("#id_error_retention_current");c.length>0&&b.text(e)})}.bind(this))},{init:function(a){return d(),new c(a)}}});
|
||||
define(["jquery"],function(a){var b={PURPOSE_SELECT:"#id_purposeid",RETENTION_FIELD_BOOST:"#id_error_retention_current",RETENTION_FIELD_CLEAN:"#fitem_id_retention_current [data-fieldtype=static]"},c=function(a){this.purposeRetentionPeriods=a,this.registerEventListeners()},d=function(){a(b.PURPOSE_SELECT).off("change")};return c.prototype.purposeRetentionPeriods=[],c.prototype.registerEventListeners=function(){a(b.PURPOSE_SELECT).on("change",function(c){var d=a(c.currentTarget).val(),e=this.purposeRetentionPeriods[d],f=a(b.RETENTION_FIELD_CLEAN);if(f.length>0)f.text(e);else{var g=a(b.RETENTION_FIELD_BOOST),h=g.siblings();h.length>0&&h.text(e)}}.bind(this))},{init:function(a){return d(),new c(a)}}});
|
@ -26,7 +26,8 @@ define(['jquery'],
|
||||
|
||||
var SELECTORS = {
|
||||
PURPOSE_SELECT: '#id_purposeid',
|
||||
RETENTION_FIELD: '.form-control-static',
|
||||
RETENTION_FIELD_BOOST: '#id_error_retention_current',
|
||||
RETENTION_FIELD_CLEAN: '#fitem_id_retention_current [data-fieldtype=static]',
|
||||
};
|
||||
|
||||
/**
|
||||
@ -65,14 +66,16 @@ define(['jquery'],
|
||||
var selected = $(ev.currentTarget).val();
|
||||
var selectedPurpose = this.purposeRetentionPeriods[selected];
|
||||
|
||||
$(SELECTORS.RETENTION_FIELD).each(function() {
|
||||
var node = $(this);
|
||||
// Sucky way to select the text, but no id for static fields :(.
|
||||
var retentionField = node.siblings('#id_error_retention_current');
|
||||
var cleanSelector = $(SELECTORS.RETENTION_FIELD_CLEAN);
|
||||
if (cleanSelector.length > 0) {
|
||||
cleanSelector.text(selectedPurpose);
|
||||
} else {
|
||||
var boostSelector = $(SELECTORS.RETENTION_FIELD_BOOST);
|
||||
var retentionField = boostSelector.siblings();
|
||||
if (retentionField.length > 0) {
|
||||
node.text(selectedPurpose);
|
||||
retentionField.text(selectedPurpose);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user