Picture of aaron quinn
Re: how do i reset a component?
by aaron quinn - Friday, 13 January 2017, 9:38 PM
 

thanks matt, this really helps me a lot.

currently, i'm working on a plugin that has a span which updates its color when clicked, and its targeted object is set to _isVisited = true

clicking the span also completes the component

upon returning to the page the component is complete, remembers that the object isVisited, and that the span has been clicked and is the updated color.

from what i understand, if i add this to the component.json (or a string value of "hard")...

 

"displayTitle": "Component Name",
"title": "Component Name",
"_isResetOnRevisit": true,
"_isAvailable": true,
"_isOptional": false,
"_classes": "",
"_component": "some-component",
"_pageLevelProgress": {
"_isEnabled": true
},

 

...the component needs to be completed again, so the span and it's targeted object should be reset. and if the string value is "soft" the component remains complete, but if i choose, i can reset the colors (or whatever the interactivity may be) and i would do that in the "if":

 

// If reset is enabled set defaults
if (isResetOnRevisit) {
this.model.reset(isResetOnRevisit);
//reset stuff here
}

 

can this "_isResetOnRevisit": true, be a property i include in the component's properties.schema so it can be set with a dropdown?

thanks for your input :)

Picture of Matt Leathes
Re: how do i reset a component?
by Matt Leathes - Tuesday, 24 January 2017, 7:50 PM
 

Hi Aaron

Sorry for the slow response...

As _isResetOnRevisit is listed as one of the Core Model Attributes, I'm a little bit surprised to find it's not already available as a setting in the AT for all components - just like _isOptional and _isAvailable are. I'm not quite sure why that should be... maybe someone else can shed some light on why? It may just be an oversight...

Regardless I don't see any reason why you shouldn't be able to add it to your component's properties.schema - the only caveat being that if it does get added to the core component schema you may have to take it out again.