Save button in Image Markup Widget

0
Hi,    I have downloaded and included the Image Markup Widget in my project. The widget is having SAVE & RESET button. How to add / include the microflow in this default button ?   Regards Sudhir
asked
2 answers
0

Hello,

In this module there are limitatios :

  • Currently there is no OnClick action when specifying a point    
  • A deafult Save button is provided, which commits the image as the entity specified in the configuration.

   So you need to use another widget.

 

Thanks,

Srilatha

answered
0

Hi Sudhir,

Kindly verify the source code below the link.

GitHub - joe-robertson-mx/imageMarker

 

 const saveImage = (): void => {
        const ctx = canvasCtxRef.current!;
        if (data.items) {
            mx.data.get({
                guids: [data.items[0].id],
                callback(objs) {
                    const obj = objs[0];
                    const entityName = obj.getEntity();
                    mx.data.create({
                        entity: entityName,
                        callback: mxObject => {
                            ctx.canvas.toBlob(blob => {
                                mx.data.saveDocument(
                                    mxObject.getGuid(),
                                    `${entityName}_${Date.now()}`,
                                    {},
                                    blob!,
                                    () => {
                                        if (context?.items) {
                                            mx.data.get({
                                                guids: [context.items[0].id],
                                                callback(objs) {
                                                    const obj = objs[0];
                                                    const entityName = obj.getEntity();
                                                    const n = entityName.lastIndexOf(".");
                                                    const entityNameTrimmed = entityName.substring(n + 1);
                                                    const refArr = mxObject.getReferenceAttributes();
                                                    const ref = refArr.find(str => {
                                                        return str.includes(entityNameTrimmed);
                                                    });
                                                    if (ref) {
                                                        mxObject.addReference(ref, obj.getGuid());
                                                        mx.data.commit({
                                                            mxobj: mxObject,
                                                            callback: () => {},
                                                            error: e => {
                                                                console.log(
                                                                    "Error occurred attempting to commit: " + e
                                                                );
                                                            }
                                                        });
                                                    }
                                                },
                                                error: e => {
                                                    console.log(e);
                                                }
                                            });
                                        }
                                    },
                                    e => {
                                        console.log(e);
                                    }
                                );
                            });
                        },
                        error: e => {
                            console.log(e);
                        }
                    });
                }
            });
        }
    };

you should alter this part of code according to use case. Try to update widget cheers.

answered