Commit 6f77083c authored by benjaminParisel's avatar benjaminParisel Committed by abirembaut

fix(widgetAsset): Desactivate widget asset (#2531)

* For widget asset, id is not defined in ***.json, so now with use name
to save activate state

Covers [BS-19006](https://bonitasoft.atlassian.net/browse/BS-19006)
parent 69be03ed
......@@ -117,7 +117,11 @@ public class AssetVisitor implements ElementVisitor<Set<Asset>> {
//User can exclude assets or specify a specific order in the page
for (Asset asset : assets) {
asset.setActive(!previewable.getInactiveAssets().contains(asset.getId()));
if (asset.getId() != null) {
asset.setActive(!previewable.getInactiveAssets().contains(asset.getId()));
} else {
asset.setActive(!previewable.getInactiveAssets().contains(asset.getName()));
}
}
}
......
......@@ -205,4 +205,26 @@ public class AssetVisitorTest {
assertThat(assets).extracting("name").containsExactly("myfile.js", "myfile.js");
}
@Test
public void should_good_list_widget_asset__if_one_is_inactive() throws Exception {
Component component = mockComponentFor(
aWidget(),
"id1",
anAsset().withName("myfileBis.js").withType(AssetType.JAVASCRIPT),
anAsset().withName("http://mycdn.com/myfile.js").withType(AssetType.JAVASCRIPT)
);
Page page = aPage().with(component)
.withAsset(
anAsset().withId("assetUIID1").withName("myfile.js").withType(AssetType.JAVASCRIPT).build(),
anAsset().withId("assetUIID2").withName("myfile.css").withType(AssetType.CSS).build()
)
.withInactiveAsset("assetUIID2", "myfileBis.js")
.build();
Set<Asset> assets = assetVisitor.visit(page);
assertThat(assets).extracting("name").contains("myfile.js", "myfile.css", "myfileBis.js", "http://mycdn.com/myfile.js");
assertThat(assets).extracting("active").contains(true, false, true, false);
}
}
......@@ -62,7 +62,7 @@
var inactiveAssets = vm.component.assets.filter(function(asset) {
return !asset.active;
}).map(function(asset) {
return asset.id;
return asset.id || asset.name;
});
vm.component.inactiveAssets = (inactiveAssets.length) ? inactiveAssets : undefined;
}
......
......@@ -38,7 +38,8 @@
}
desactivateAsset(pageId, asset) {
return this.$http.put(`${this.baseUrl}/${pageId}/assets/${asset.id}?active=${asset.active}`, asset);
var assetId = asset.id || asset.name;
return this.$http.put(`${this.baseUrl}/${pageId}/assets/${assetId}?active=${asset.active}`, asset);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment