Amplitude analysis of the anomalous decay $\eta'\to\pi^+\pi^-\gamma$